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
end
get '/browse' do
@sites = Site.order(:id.desc).filter(initial_index_changed: true).all
slim :browse
end
get '/new' do
dashboard_if_signed_in
@site = Site.new
@ -145,6 +150,8 @@ 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
flash[:success] = "Successfully uploaded file #{sanitized_filename}."
redirect '/dashboard'
end
@ -205,6 +212,8 @@ 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
'ok'
end

View file

@ -73,10 +73,13 @@ class Site < Sequel::Model
end
# Check for existing user
if new?
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
if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH)
errors.add :password, "Password must be at least #{MINIMUM_PASSWORD_LENGTH} characters."

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>
div.text-center
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>

View file

@ -49,16 +49,16 @@ css:
.row
.span12
div id="editor" style="width: 100%; height: 1000px; position: relative;"
div id="editor" style="width: 100%; height: 600px; position: relative;"
#{@file_data}
.row.text-center style="margin-top: 10px"
.span4
a.btn.btn-large.btn-warning href="/dashboard" <i class="icon-remove"></i>&nbsp;&nbsp;Finish Without Saving
.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
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"
.span6.offset3.text-center