diff --git a/app.rb b/app.rb
index c7227b5f..8aa87ca9 100644
--- a/app.rb
+++ b/app.rb
@@ -28,7 +28,12 @@ end
get '/blog' do
# expires 500, :public, :must_revalidate
- return File.read File.join(DIR_ROOT, 'public', 'sites', 'kyledrake', 'blog.html')
+ return File.read File.join(DIR_ROOT, 'public', 'sites', 'blog', 'blog.html')
+end
+
+get '/blog/:id-:name' do
+ # expires 500, :public, :must_revalidate
+ return File.read File.join(DIR_ROOT, 'public', 'sites', 'blog', "blog-#{params[:id]}.html")
end
get '/new' do
@@ -99,15 +104,47 @@ get '/signout' do
redirect '/'
end
+get '/about' do
+ slim :'about'
+end
+
+get '/site_files/new_page' do
+ require_login
+ slim :'site_files/new_page'
+end
+
+post '/site_files/create_page' do
+ require_login
+ @errors = []
+
+ params[:pagefilename].gsub!(/[^a-zA-Z0-9_\-.]/, '')
+ params[:pagefilename].gsub!(/\.html$/i, '')
+
+ if params[:pagefilename].nil? || params[:pagefilename].empty?
+ @errors << 'You must provide a file name.'
+ halt slim(:'site_files/new_page')
+ end
+
+ name = "#{params[:pagefilename]}.html"
+ path = site_file_path name
+
+ if File.exist? path
+ @errors << %{Web page "#{name}" already exists! Choose another name.}
+ halt slim(:'site_files/new_page')
+ end
+
+ File.write path, slim(:'templates/index', pretty: true, layout: false)
+
+ flash[:success] = %{#{name} was created! Click here to edit it.}
+
+ redirect '/dashboard'
+end
+
get '/site_files/new' do
require_login
slim :'site_files/new'
end
-get '/about' do
- slim :'about'
-end
-
post '/site_files/upload' do
require_login
@errors = []
diff --git a/views/dashboard.slim b/views/dashboard.slim
index 72ba53cd..a6344d43 100644
--- a/views/dashboard.slim
+++ b/views/dashboard.slim
@@ -64,8 +64,11 @@ javascript:
.row style="margin-top: 20px"
.span5
-
- Upload New File
+ div
+ a href="/site_files/new" class="btn btn-large btn-success" style="margin-bottom:20px" Upload New File
+ div
+ a href="/site_files/new_page" class="btn btn-large btn-success" style="margin-bottom: 20px" Create New HTML Page
+
h4: a href="/site_files/#{current_site.username}.zip" Download Entire Site
form method="POST" action="/site_files/delete" id="deleteFilenameForm"
diff --git a/views/index.slim b/views/index.slim
index a8a72ee3..45de2d5d 100644
--- a/views/index.slim
+++ b/views/index.slim
@@ -26,11 +26,12 @@
td With donations. It's not that expensive. If you feel this is a useful service, click here to contribute!
.row
- .span5.offset1
- h2: a href="/browse" BROWSE EXISTING SITES
- .span5.offset1
- h2: a href="/new" CREATE A WEB SITE
+ .span5.offset2
+ a.btn.btn-large.btn-success style="font-size: 20pt" href="/browse" Browse Existing Sites
+ .span5
+ a.btn.btn-large.btn-success style="font-size: 20pt" href="/new" Create a Web Site
h5 Returning users: Sign In
.row
.span6.offset3
- h4 style="line-height: 22pt" There are #{Server.first.slots_available} web site spaces remaining.
After that, we need your help to get another server.
HELP NEOCITIES PROSPER
+ h4 style="line-height: 22pt" There are #{Server.first.slots_available} web site spaces remaining.
After that, we need your help to get another server.
+ div.text-center: a class="btn btn-large btn-success" href="/about" Help Neocities Prosper
diff --git a/views/layout.slim b/views/layout.slim
index 5c33cdb2..65a34b3f 100644
--- a/views/layout.slim
+++ b/views/layout.slim
@@ -35,7 +35,7 @@ html
- flash.keys.each do |key|
div class="alert alert-#{key}"
button.close type="button" data-dismiss="alert" ×
- = flash[key]
+ == flash[key]
container
== yield
diff --git a/views/site_files/new_page.slim b/views/site_files/new_page.slim
new file mode 100644
index 00000000..0d709f18
--- /dev/null
+++ b/views/site_files/new_page.slim
@@ -0,0 +1,25 @@
+- if @errors
+ .row
+ .span8.offset2
+ div.alert.alert-error
+ h3 There were errors, please correct:
+ - @errors.each do |error|
+ h5 = error
+
+.row
+ .span12.text-center
+ h1 Create new HTML page
+
+.row
+ .span12.text-center
+ form method="POST" action="/site_files/create_page" enctype="multipart/form-data"
+ input name="csrf_token" type="hidden" value="#{csrf_token}"
+ h4 What's the name of your page?
+ h4: input type="text" name="pagefilename".html
+ p: input.btn.btn-success.btn-large type="submit" value="Create Page"
+
+.row
+ .span6.offset3
+ h5 Note: We will automatically scrub any characters not matching: a-z A-Z 0-9 _ - .
+ h5 Page must not already exist.
+ h5 If you want to make this the index page (and an index page doesn't exist), name it index.html.
\ No newline at end of file