polish for browsing, add hit counter

This commit is contained in:
Kyle Drake 2013-06-20 19:52:14 -07:00
parent e2d19d35ae
commit d535bee286
5 changed files with 18 additions and 6 deletions

View file

@ -13,6 +13,7 @@ gem 'rack-recaptcha', require: 'rack/recaptcha'
gem 'rmagick', require: nil
gem 'selenium-webdriver', require: nil
gem 'backburner'
gem 'ago'
platform :mri do
gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic

View file

@ -2,6 +2,8 @@ GEM
remote: https://rubygems.org/
specs:
addressable (2.3.4)
ago (0.1.5)
hoe (>= 1.12.2)
ansi (1.4.3)
backburner (0.3.4)
beaneater (~> 0.3.0)
@ -27,6 +29,8 @@ GEM
ffi (1.4.0)
hashie (2.0.5)
hiredis (0.4.5)
hoe (3.6.3)
rake (>= 0.8, < 11.0)
i18n (0.6.4)
json (1.8.0)
kgio (2.8.0)
@ -114,6 +118,7 @@ PLATFORMS
ruby
DEPENDENCIES
ago
backburner
bcrypt-ruby
fabrication

6
app.rb
View file

@ -35,7 +35,7 @@ get '/?' do
end
get '/browse' do
@sites = Site.order(:id.desc).filter(initial_index_changed: true).all
@sites = Site.order(:id.desc).filter(~{updated_at: nil}).all
slim :browse
end
@ -150,7 +150,7 @@ post '/site_files/upload' do
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/
current_site.update initial_index_changed: true if current_site.initial_index_changed == false
current_site.update updated_at: Time.now
flash[:success] = "Successfully uploaded file #{sanitized_filename}."
redirect '/dashboard'
@ -212,7 +212,7 @@ post '/site_files/save/:filename' do |filename|
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/
current_site.update initial_index_changed: true if current_site.initial_index_changed == false
current_site.update updated_at: Time.now
'ok'
end

View file

@ -1,12 +1,17 @@
.row
.span12.text-center
h1 Home Pages on NeoCities
p Want to make your own? <a href="/new">Click here</a>!
p If you like a site, don't forget to bookmark it!<br>Want to make your own? <a href="/new">Click here</a>!
- @sites.each_with_index do |site,i|
- if i.even? && i != 0
.row
.span6.text-center
h3: a href="http://#{site.username}.neocities.org" target="_blank" #{site.username}
.span6 style="background-color: #F8F8F8; margin-bottom: 30px"
.row
.span3
h3 style="margin-left: 20px": a href="http://#{site.username}.neocities.org" target="_blank" #{site.username}
.span3.text-right
p style="margin-right: 20px; margin-top: 10px" #{site.hits} hits<br>last updated #{site.updated_at.ago}
a href="http://#{site.username}.neocities.org" target="_blank": img src="/site_screenshots/#{ENV['RACK_ENV'] == 'development' ? 'victoria' : site.username}.jpg"

View file

@ -21,6 +21,7 @@ html
.navbar-inner
a.brand href="/" NeoCities
ul.nav.pull-right
li: a href="/browse" <b>Browse</b>
- if signed_in?
li.navbar-text: strong style="color: #7AB800" #{current_site.username}
li: a href="/signout" style="color: #B94A48" Signout