mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 16:51:36 +02:00
Numerous small copy changes here and there, blog feed on front page, added a press article
This commit is contained in:
parent
f0ca037237
commit
eed42b7558
8 changed files with 69 additions and 28 deletions
20
app/index.rb
20
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), 600 # 10 Minutes
|
||||
@sites_count = SimpleCache.store :sites_count, Site.count.roundup(100), 10.minutes
|
||||
else
|
||||
@sites_count = SimpleCache.get :sites_count
|
||||
end
|
||||
|
||||
if SimpleCache.expired?(:blog_feed_html)
|
||||
@blog_feed_html = ''
|
||||
|
||||
begin
|
||||
xml = HTTP.timeout(read: 2, write: 2, connect: 2).get('https://blog.neocities.org/feed.xml').to_s
|
||||
feed = Feedjira::Feed.parse xml
|
||||
feed.entries[0..2].each do |entry|
|
||||
@blog_feed_html += %{<a href="#{entry.url}">#{entry.title.split('.').first}</a> <span style="float: right">#{entry.published.strftime('%b %-d, %Y')}</span><br>}
|
||||
end
|
||||
rescue
|
||||
@blog_feed_html = 'The latest news on Neocities can be found on our blog.'
|
||||
end
|
||||
|
||||
@blog_feed_html = SimpleCache.store :blog_feed_html, @blog_feed_html, 8.hours
|
||||
else
|
||||
@blog_feed_html = SimpleCache.get :blog_feed_html
|
||||
end
|
||||
|
||||
erb :index, layout: :index_layout
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue