From 4a33f3f9d3cea00f5aa9552a46c9389a325fea1d Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 23 Jun 2017 10:25:20 -0700 Subject: [PATCH] Add hit/view/update stats to Neocities front page --- app/index.rb | 20 +++++++++++++++++++- sass/_project-sass/_project-Main.scss | 20 ++++++++++++++++++++ views/index.erb | 16 +++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/index.rb b/app/index.rb index 06b033d2..b13d8dc3 100644 --- a/app/index.rb +++ b/app/index.rb @@ -31,11 +31,29 @@ get '/?' do end 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 @sites_count = SimpleCache.get :sites_count 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) @blog_feed_html = '' diff --git a/sass/_project-sass/_project-Main.scss b/sass/_project-sass/_project-Main.scss index 61d11831..2521a793 100644 --- a/sass/_project-sass/_project-Main.scss +++ b/sass/_project-sass/_project-Main.scss @@ -1469,6 +1469,7 @@ a.tag:hover { margin-bottom: 0; } } + .section.support { padding-bottom: 100px; p { @@ -1506,6 +1507,25 @@ a.tag:hover { .section.features p, .section.features h3 { 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 { display: inline-block; clear: both; diff --git a/views/index.erb b/views/index.erb index 98ca079d..59d2f1b8 100644 --- a/views/index.erb +++ b/views/index.erb @@ -242,8 +242,22 @@

Open Source

We publish the code that powers the site for inspection. We want to win your trust—not lock you in.

+ - +
+
+
+

<%= @total_hits_count.to_comma_separated %>

+

Site Hits

+
+
+

<%= @total_views_count.to_comma_separated %>

+

Site Visitors

+
+
+

<%= @changed_count.to_comma_separated %>

+

Site Updates

+