diff --git a/app/activity.rb b/app/activity.rb
index 42cfc619..5bd22c91 100644
--- a/app/activity.rb
+++ b/app/activity.rb
@@ -1,9 +1,11 @@
get '/activity' do
@page = params[:page] || 1
+ @description = 'See recent activity from Neocities websites.'
halt 404 if params[:event_id]
if params[:tag]
+ @description = "See recent activity from Neocities websites tagged #{params[:tag]}."
query1 = Event
.join(:sites, id: :site_id)
.join(:sites_tags, site_id: :id)
@@ -51,4 +53,4 @@ get '/activity' do
@events = @pagination_dataset.all
erb :'activity'
-end
\ No newline at end of file
+end
diff --git a/app/api.rb b/app/api.rb
index 1730cf08..8346f4c9 100644
--- a/app/api.rb
+++ b/app/api.rb
@@ -2,6 +2,7 @@ require 'base64'
get '/api' do
@title = 'Developers API'
+ @description = 'Use the Neocities API to upload files and manage your site programmatically.'
erb :'api'
end
diff --git a/app/browse.rb b/app/browse.rb
index a1c547b6..db94ca21 100644
--- a/app/browse.rb
+++ b/app/browse.rb
@@ -1,10 +1,12 @@
get '/browse/?' do
@page = params[:page]
@page = 1 if @page.not_an_integer?
+ @description = 'Browse Neocities websites by tags, popularity, and recent updates.'
if params[:tag]
params[:tag] = params[:tag].gsub(Tag::INVALID_TAG_REGEX, '').gsub(/\s+/, '').slice(0, Tag::NAME_LENGTH_MAX)
@title = "Sites tagged #{params[:tag]}"
+ @description = "Browse Neocities websites tagged #{params[:tag]}."
end
if is_education?
@@ -135,6 +137,7 @@ end
get '/browse/search' do
@title = 'Site Search'
+ @description = 'Search websites hosted on Neocities.'
@daily_search_max_reached = daily_search_max?
diff --git a/app/contact.rb b/app/contact.rb
index d0198007..e5e49778 100644
--- a/app/contact.rb
+++ b/app/contact.rb
@@ -1,5 +1,6 @@
get '/contact' do
@show_contact_form = params[:show_contact_form] == 'yes'
+ @description = 'Contact Neocities support and get help with your account or site.'
erb :'contact'
end
diff --git a/app/dmca.rb b/app/dmca.rb
index 518b94a4..60b8e1f0 100644
--- a/app/dmca.rb
+++ b/app/dmca.rb
@@ -1,5 +1,6 @@
get '/dmca' do
@title = 'DMCA'
+ @description = 'Submit a DMCA notice and review copyright policy information for Neocities.'
erb :'dmca'
end
diff --git a/app/index.rb b/app/index.rb
index f9659462..c22ddf55 100644
--- a/app/index.rb
+++ b/app/index.rb
@@ -101,6 +101,7 @@ get '/?' do
end
@create_disabled = false
+ @description = 'Create and surf awesome websites for free.'
erb :index, layout: :index_layout
end
@@ -124,46 +125,56 @@ end
get '/education' do
redirect '/' if signed_in?
+ @description = 'Learn how educators and students use Neocities to build websites in class.'
erb :education, layout: :index_layout
end
get '/donate' do
+ @description = 'Support Neocities and help keep independent web publishing open to everyone.'
erb :'donate'
end
get '/about' do
+ @description = 'Read about the Neocities mission and the team building a better web.'
erb :'about'
end
get '/terms' do
+ @description = 'Review the Neocities Terms of Service.'
erb :'terms'
end
get '/privacy' do
+ @description = 'Review the Neocities Privacy Policy.'
erb :'privacy'
end
get '/press' do
+ @description = 'Press resources, facts, and media information about Neocities.'
erb :'press'
end
get '/legal/?' do
@title = 'Legal Guide to Neocities'
+ @description = 'Browse legal information and policy guidance for Neocities.'
erb :'legal'
end
get '/thankyou' do
@title = 'Thank you!'
+ @description = 'Thank you for supporting Neocities.'
erb :'thankyou'
end
get '/cli' do
@title = 'Command Line Interface'
+ @description = 'Use the Neocities command line tool to deploy and manage your site from terminal.'
erb :'cli'
end
get '/forgot_username' do
@title = 'Forgot Username'
+ @description = 'Recover the username for your Neocities account.'
erb :'forgot_username'
end
diff --git a/app/password_reset.rb b/app/password_reset.rb
index e6abd56a..0d138027 100644
--- a/app/password_reset.rb
+++ b/app/password_reset.rb
@@ -1,5 +1,6 @@
get '/password_reset' do
@title = 'Password Reset'
+ @description = 'Reset your Neocities account password.'
redirect '/' if signed_in?
erb :'password_reset'
end
diff --git a/app/signin.rb b/app/signin.rb
index 2ec78357..3cf25d74 100644
--- a/app/signin.rb
+++ b/app/signin.rb
@@ -1,6 +1,7 @@
get '/signin/?' do
dashboard_if_signed_in
@title = 'Sign In'
+ @description = 'Sign in to your Neocities account.'
erb :'signin/index'
end
@@ -78,4 +79,4 @@ post '/signout' do
require_login
signout
redirect '/'
-end
\ No newline at end of file
+end
diff --git a/app/site.rb b/app/site.rb
index 80f429b4..ba222549 100644
--- a/app/site.rb
+++ b/app/site.rb
@@ -15,6 +15,7 @@ get '/site/:username/?' do |username|
redirect site.uri unless site.profile_enabled
@title = site.title
+ @description = "#{site.username}'s Neocities site profile, updates, and comments."
@page = params[:page]
@page = 1 if @page.not_an_integer?
@@ -49,6 +50,7 @@ get '/site/:username/stats' do
not_found if @site.nil? || @site.is_banned || @site.is_deleted || (current_site && @site.is_blocking?(current_site))
@title = "Site stats for #{@site.host}"
+ @description = "Traffic and engagement stats for #{@site.username}'s Neocities site."
@stats = {}
@@ -136,6 +138,7 @@ end
get '/site/:username/follows' do |username|
@title = "Sites #{username} follows"
+ @description = "See which Neocities sites #{username} follows."
@site = Site[username: username]
not_found if @site.nil? || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site)))
@@ -147,6 +150,7 @@ end
get '/site/:username/followers' do |username|
@title = "Sites that follow #{username}"
+ @description = "See which Neocities sites follow #{username}."
@site = Site[username: username]
not_found if @site.nil? || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site)))
diff --git a/app/site_files.rb b/app/site_files.rb
index 42ae30e8..8fa5a294 100644
--- a/app/site_files.rb
+++ b/app/site_files.rb
@@ -131,16 +131,19 @@ end
get '/site_files/allowed_types' do
@title = 'Allowed File Types'
+ @description = 'See which file types can be uploaded to Neocities sites.'
erb :'site_files/allowed_types'
end
get '/site_files/hotlinking' do
@title = 'Hotlinking Information'
+ @description = 'Learn how hotlinking works on Neocities.'
erb :'site_files/hotlinking'
end
get '/site_files/mount_info' do
@title = 'Site Mount Information'
+ @description = 'Read how to mount and manage your Neocities site files.'
erb :'site_files/mount_info'
end
@@ -176,4 +179,4 @@ post '/site_files/chat' do
out << buffer
end
end
-end
\ No newline at end of file
+end
diff --git a/app/tutorial.rb b/app/tutorial.rb
index 582308ec..8d2d0dff 100644
--- a/app/tutorial.rb
+++ b/app/tutorial.rb
@@ -14,6 +14,7 @@ EOT
end
get '/tutorials' do
+ @description = 'Start web development tutorials on Neocities.'
erb :'tutorials'
end
diff --git a/app_helpers.rb b/app_helpers.rb
index 6a75ccad..c888c4a6 100644
--- a/app_helpers.rb
+++ b/app_helpers.rb
@@ -56,6 +56,17 @@ def meta_robots(newtag=nil)
@_meta_robots
end
+def meta_description(new_description=nil)
+ if new_description
+ @_meta_description = new_description
+ end
+
+ description = @_meta_description || @description
+ return nil if description.nil? || description.strip.empty?
+
+ Rack::Utils.escape_html(description)
+end
+
def title
out = "Neocities"
return out if request.path == '/'
diff --git a/views/_meta.erb b/views/_meta.erb
index 1395c314..a485baa2 100644
--- a/views/_meta.erb
+++ b/views/_meta.erb
@@ -1,5 +1,8 @@
-
+<% description = meta_description %>
+<% if description %>
+
+<% end %>
<% canonical_host = @canonical_host || 'https://neocities.org' %>
<% canonical_path = @canonical_path || request.fullpath %>
@@ -8,7 +11,9 @@
-
+<% if description %>
+
+<% end %>