cached global activity feed, publicly acessible #69

This commit is contained in:
Kyle Drake 2015-02-15 13:18:54 -08:00
parent 41a7cb763d
commit 60f9b5b589
7 changed files with 67 additions and 51 deletions

6
app/activity.rb Normal file
View file

@ -0,0 +1,6 @@
get '/activity' do
expires 14400, :public, :must_revalidate if self.class.production? # 4 hours
params[:activity] = 'global' # FIXME this is a bad hack
@events = Event.global_dataset.all
erb :'activity'
end

View file

@ -15,7 +15,7 @@ class Event < Sequel::Model
DEFAULT_GLOBAL_LIMIT = 100
GLOBAL_VIEWS_MINIMUM = 500
def self.global_dataset(current_page, limit=DEFAULT_GLOBAL_LIMIT)
def self.global_dataset(current_page=1, limit=DEFAULT_GLOBAL_LIMIT)
select_all(:events).
order(:created_at.desc).
paginate(current_page, 100).

View file

@ -7,21 +7,7 @@
</a>
<ul class="h-Nav constant-Nav">
<li>
<a href="/browse">Websites</a>
</li>
<li>
<a href="/about">About</a>
</li>
<li>
<a href="/tutorials">Tutorials</a>
</li>
<li>
<a href="/api">API</a>
</li>
<li>
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
</li>
<%== erb :'_header_links', layout: false %>
</ul>
<ul class="status-Nav">

23
views/_header_links.erb Normal file
View file

@ -0,0 +1,23 @@
<% if request.path == '/' %>
<li>
<a href="/">Neocities</a>
</li>
<% end %>
<li>
<a href="/browse">Websites</a>
</li>
<li>
<a href="/activity">Activity</a>
</li>
<li>
<a href="/about">About</a>
</li>
<li>
<a href="/tutorials">Tutorials</a>
</li>
<li>
<a href="/api">API</a>
</li>
<li>
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
</li>

26
views/activity.erb Normal file
View file

@ -0,0 +1,26 @@
<div class="header-Outro with-columns">
<div class="row content">
<div class="col col-100">
<h3>Latest Activity on Neocities</h3>
</div>
</div>
</div>
<div class="container">
<div class="content misc-page columns">
<div class="col-left">
<div class="col col-100">
<% if !signed_in? %>
<div class="welcome">
<h4>All the latest Neocities site news!</h4>
<p>
Neocities allows everyone create a free web site to express themselves. Want to create your own websome site? <a href="/#new">Join us!</a>
</p>
</div>
<% end %>
<%== erb :'_news', locals: {current_site: nil, events: @events} %>
</div>
</div>
</div>
</div>

View file

@ -1,22 +1,14 @@
<div class="header-Outro with-columns">
<div class="row content">
<div class="col col-66">
<h3>
<% if params[:activity] == 'global' %>
Global Feed
<% else %>
Your Feed
<% end %>
</h3>
<h3>Your Feed</h3>
<div class="feed-filter">
<% if !@events.empty? && (site.followings_dataset.count > 0) %>
<a href="/" <% if params[:activity].nil? %>class="selected"<% end %>>All Activity</a>
&nbsp;&nbsp;
<a href="/?activity=mine" <% if params[:activity] == 'mine' %>class="selected"<% end %>>
Activity on your profile
</a>
<a href="/?activity=mine" <% if params[:activity] == 'mine' %>class="selected"<% end %>>Activity on your profile</a>
<% end %>
<a href="/?activity=global" <% if params[:activity] == 'global' %>class="selected"<% end %>>Global Activity</a>
<a href="/activity">Global Activity</a>
</div>
</div>
<div class="col col-32">

View file

@ -51,24 +51,7 @@
<img src="/img/nav-Icon.png" alt="navigation icon" />
</a>
<ul class="h-Nav constant-Nav" role="presentation">
<li>
<a href="/">Neocities</a>
</li>
<li>
<a href="/browse">Websites</a>
</li>
<li>
<a href="/about">About</a>
</li>
<li>
<a href="/tutorials">Tutorials</a>
</li>
<li>
<a href="/api">API</a>
</li>
<li>
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
</li>
<%== erb :'_header_links', layout: false %>
</ul>
<ul class="status-Nav">