mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Add hit/view/update stats to Neocities front page
This commit is contained in:
parent
ffb67cd3a8
commit
4a33f3f9d3
3 changed files with 54 additions and 2 deletions
20
app/index.rb
20
app/index.rb
|
@ -31,11 +31,29 @@ get '/?' do
|
||||||
end
|
end
|
||||||
|
|
||||||
if SimpleCache.expired?(:sites_count)
|
if SimpleCache.expired?(:sites_count)
|
||||||
@sites_count = SimpleCache.store :sites_count, Site.count.roundup(100), 10.minutes
|
@sites_count = SimpleCache.store :sites_count, Site.count.roundup(100), 4.hours
|
||||||
else
|
else
|
||||||
@sites_count = SimpleCache.get :sites_count
|
@sites_count = SimpleCache.get :sites_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if SimpleCache.expired?(:total_hits_count)
|
||||||
|
@total_hits_count = SimpleCache.store :total_hits_count, DB['SELECT SUM(hits) AS hits FROM SITES'].first[:hits], 4.hours
|
||||||
|
else
|
||||||
|
@total_hits_count = SimpleCache.get :total_hits_count
|
||||||
|
end
|
||||||
|
|
||||||
|
if SimpleCache.expired?(:total_views_count)
|
||||||
|
@total_views_count = SimpleCache.store :total_views_count, DB['SELECT SUM(views) AS views FROM SITES'].first[:views], 4.hours
|
||||||
|
else
|
||||||
|
@total_views_count = SimpleCache.get :total_views_count
|
||||||
|
end
|
||||||
|
|
||||||
|
if SimpleCache.expired?(:changed_count)
|
||||||
|
@changed_count = SimpleCache.store :changed_count, DB['SELECT SUM(changed_count) AS changed_count FROM SITES'].first[:changed_count], 4.hours
|
||||||
|
else
|
||||||
|
@changed_count = SimpleCache.get :changed_count
|
||||||
|
end
|
||||||
|
|
||||||
if SimpleCache.expired?(:blog_feed_html)
|
if SimpleCache.expired?(:blog_feed_html)
|
||||||
@blog_feed_html = ''
|
@blog_feed_html = ''
|
||||||
|
|
||||||
|
|
|
@ -1469,6 +1469,7 @@ a.tag:hover {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.section.support {
|
.section.support {
|
||||||
padding-bottom: 100px;
|
padding-bottom: 100px;
|
||||||
p {
|
p {
|
||||||
|
@ -1506,6 +1507,25 @@ a.tag:hover {
|
||||||
.section.features p, .section.features h3 {
|
.section.features p, .section.features h3 {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
.section .stats {
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
}
|
||||||
|
.section .stats h2 {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 3em;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
@media (max-device-width:480px), screen and (max-width:1200px){
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 1.8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.section .stats h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
.section .press {
|
.section .press {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
clear: both;
|
clear: both;
|
||||||
|
|
|
@ -242,8 +242,22 @@
|
||||||
<h3><i class="fa fa-university"></i>Open Source</h3>
|
<h3><i class="fa fa-university"></i>Open Source</h3>
|
||||||
<p>We <a href="https://github.com/neocities" target="_blank">publish</a> the code that powers the site for inspection. We want to win your trust—not lock you in.</p>
|
<p>We <a href="https://github.com/neocities" target="_blank">publish</a> the code that powers the site for inspection. We want to win your trust—not lock you in.</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col col-100">
|
||||||
|
<div class="row stats">
|
||||||
|
<div class="col col-33">
|
||||||
|
<h2><%= @total_hits_count.to_comma_separated %></h2>
|
||||||
|
<h3 style="text-align: center">Site Hits</h3>
|
||||||
|
</div>
|
||||||
|
<div class="col col-33">
|
||||||
|
<h2><%= @total_views_count.to_comma_separated %></h2>
|
||||||
|
<h3 style="text-align: center">Site Visitors</h3>
|
||||||
|
</div>
|
||||||
|
<div class="col col-33">
|
||||||
|
<h2><%= @changed_count.to_comma_separated %></h2>
|
||||||
|
<h3 style="text-align: center">Site Updates</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col col-100">
|
<div class="col col-100">
|
||||||
|
|
Loading…
Add table
Reference in a new issue