initial browsing page

This commit is contained in:
Kyle Drake 2013-06-20 14:56:04 -07:00
parent b057ecc7a1
commit d0a359283e
4 changed files with 21 additions and 8 deletions

9
app.rb
View file

@ -34,6 +34,11 @@ get '/?' do
slim :index slim :index
end end
get '/browse' do
@sites = Site.order(:id.desc).filter(initial_index_changed: true).all
slim :browse
end
get '/new' do get '/new' do
dashboard_if_signed_in dashboard_if_signed_in
@site = Site.new @site = Site.new
@ -145,6 +150,8 @@ post '/site_files/upload' do
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/ 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
flash[:success] = "Successfully uploaded file #{sanitized_filename}." flash[:success] = "Successfully uploaded file #{sanitized_filename}."
redirect '/dashboard' redirect '/dashboard'
end end
@ -205,6 +212,8 @@ post '/site_files/save/:filename' do |filename|
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/ 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
'ok' 'ok'
end end

View file

@ -73,9 +73,12 @@ class Site < Sequel::Model
end end
# Check for existing user # Check for existing user
user = self.class.select(:username).filter(username: values[:username]).first
if !user.nil? && (user.id != values[:id]) if new?
errors.add :username, 'This username is already taken. Try using another one.' user = self.class.select(:username).filter(username: values[:username]).first
if !user.nil? && (user.id != values[:id])
errors.add :username, 'This username is already taken. Try using another one.'
end
end end
if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH) if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH)

View file

@ -26,6 +26,7 @@
td Hopefully with donations. If you feel this is a useful service, help us pay the bills to run it. <a href="/donate">Click here to contribute!</a> td Hopefully with donations. If you feel this is a useful service, help us pay the bills to run it. <a href="/donate">Click here to contribute!</a>
div.text-center div.text-center
h1: a href="/new" JOIN NOW h1: a href="/new" JOIN NOW
p or
h1: a href="/browse" BROWSE EXISTING SITES
h5 style="margin-top: 30px" Returning users: <a href="/signin">Sign In</a> h5 style="margin-top: 30px" Returning users: <a href="/signin">Sign In</a>

View file

@ -49,16 +49,16 @@ css:
.row .row
.span12 .span12
div id="editor" style="width: 100%; height: 1000px; position: relative;" div id="editor" style="width: 100%; height: 600px; position: relative;"
#{@file_data} #{@file_data}
.row.text-center style="margin-top: 10px" .row.text-center style="margin-top: 10px"
.span4 .span4
a.btn.btn-large.btn-warning href="/dashboard" <i class="icon-remove"></i>&nbsp;&nbsp;Finish Without Saving a.btn.btn-large.btn-warning href="/dashboard" <i class="icon-remove"></i>&nbsp;&nbsp;Finish Without Saving
.span4 .span4
a.btn.btn-large.btn-success href="#" onclick="saveTextFile(false)" <i class="icon-save"></i>&nbsp;&nbsp;Save Changes a.btn.btn-large.btn-success href="#" onclick="saveTextFile(false); return false" <i class="icon-save"></i>&nbsp;&nbsp;Save Changes
.span4 .span4
a.btn.btn-large.btn-info href="#" onclick="saveTextFile(true);" <i class="icon-save"></i>&nbsp;&nbsp;Save and Finish a.btn.btn-large.btn-info href="#" onclick="saveTextFile(true); return false" <i class="icon-save"></i>&nbsp;&nbsp;Save and Finish
.row style="margin-top: 20px" .row style="margin-top: 20px"
.span6.offset3.text-center .span6.offset3.text-center