diff --git a/app.rb b/app.rb
index a41a31ad..0124c72b 100644
--- a/app.rb
+++ b/app.rb
@@ -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
diff --git a/models/site.rb b/models/site.rb
index ba9d4b13..33376d31 100644
--- a/models/site.rb
+++ b/models/site.rb
@@ -73,9 +73,12 @@ class Site < Sequel::Model
end
# Check for existing user
- 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.'
+
+ 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)
diff --git a/views/index.slim b/views/index.slim
index 6fa5e75c..504d82b4 100644
--- a/views/index.slim
+++ b/views/index.slim
@@ -26,6 +26,7 @@
td Hopefully with donations. If you feel this is a useful service, help us pay the bills to run it. Click here to contribute!
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: Sign In
-
+ h5 style="margin-top: 30px" Returning users: Sign In
\ No newline at end of file
diff --git a/views/site_files/text_editor.slim b/views/site_files/text_editor.slim
index 641a088b..42fcf254 100644
--- a/views/site_files/text_editor.slim
+++ b/views/site_files/text_editor.slim
@@ -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" Finish Without Saving
.span4
- a.btn.btn-large.btn-success href="#" onclick="saveTextFile(false)" Save Changes
+ a.btn.btn-large.btn-success href="#" onclick="saveTextFile(false); return false" Save Changes
.span4
- a.btn.btn-large.btn-info href="#" onclick="saveTextFile(true);" Save and Finish
+ a.btn.btn-large.btn-info href="#" onclick="saveTextFile(true); return false" Save and Finish
.row style="margin-top: 20px"
.span6.offset3.text-center