mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 08:42:00 +02:00
further cleanups to app.rb
This commit is contained in:
parent
4cbcc3a5e9
commit
60e6697529
10 changed files with 261 additions and 279 deletions
62
app/index.rb
Normal file
62
app/index.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
get '/?' do
|
||||
if current_site
|
||||
require_login
|
||||
|
||||
@suggestions = current_site.suggestions
|
||||
|
||||
@current_page = params[:current_page].to_i
|
||||
@current_page = 1 if @current_page == 0
|
||||
|
||||
if params[:activity] == 'mine'
|
||||
events_dataset = current_site.latest_events(@current_page, 10)
|
||||
elsif params[:event_id]
|
||||
event = Event.select(:id).where(id: params[:event_id]).first
|
||||
not_found if event.nil?
|
||||
events_dataset = Event.where(id: params[:event_id]).paginate(1, 1)
|
||||
else
|
||||
events_dataset = current_site.news_feed(@current_page, 10)
|
||||
end
|
||||
|
||||
@page_count = events_dataset.page_count || 1
|
||||
@events = events_dataset.all
|
||||
|
||||
current_site.events_dataset.update notification_seen: true
|
||||
|
||||
halt erb :'home', locals: {site: current_site}
|
||||
end
|
||||
|
||||
if SimpleCache.expired?(:sites_count)
|
||||
@sites_count = SimpleCache.store :sites_count, Site.count.roundup(100), 600 # 10 Minutes
|
||||
else
|
||||
@sites_count = SimpleCache.get :sites_count
|
||||
end
|
||||
|
||||
@blackbox_question = BlackBox.generate
|
||||
@question_first_number, @question_last_number = generate_question
|
||||
|
||||
erb :index, layout: false
|
||||
end
|
||||
|
||||
get '/tutorials' do
|
||||
erb :'tutorials'
|
||||
end
|
||||
|
||||
get '/donate' do
|
||||
erb :'donate'
|
||||
end
|
||||
|
||||
get '/about' do
|
||||
erb :'about'
|
||||
end
|
||||
|
||||
get '/terms' do
|
||||
erb :'terms'
|
||||
end
|
||||
|
||||
get '/privacy' do
|
||||
erb :'privacy'
|
||||
end
|
||||
|
||||
get '/press' do
|
||||
erb :'press'
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue