From 4d06265c9c60847d0b39fe2ce5b3f2e4cf4cef43 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 22 Jul 2013 17:07:45 +0200 Subject: [PATCH 1/4] fix pagination --- app.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index 9c1d1d25..ef0c94ea 100644 --- a/app.rb +++ b/app.rb @@ -35,8 +35,9 @@ get '/?' do end get '/browse' do - @current_page = params[:current_page] || 1 + @current_page = params[:current_page] @current_page = @current_page.to_i + @current_page = 1 if @current_page == 0 site_dataset = Site.filter(is_banned: false).filter(site_changed: true).paginate(@current_page, 300) From 27bcc479d5c351659defe4de3d7c79efdc704123 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 23 Jul 2013 15:54:48 +0200 Subject: [PATCH 2/4] drop down to binary if UTF fails, don't conduct any replacing of characters --- app.rb | 9 +++++++++ views/site_files/text_editor.slim | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index ef0c94ea..a203fe99 100644 --- a/app.rb +++ b/app.rb @@ -579,3 +579,12 @@ end def template_site_title(username) "#{username.capitalize}#{username[username.length-1] == 's' ? "'" : "'s"} Site" end + +def encoding_fix(file) + begin + Rack::Utils.escape_html file + rescue ArgumentError => e + return Rack::Utils.escape_html(file.force_encoding('BINARY')) if e.message =~ /invalid byte sequence in UTF-8/ + fail + end +end diff --git a/views/site_files/text_editor.slim b/views/site_files/text_editor.slim index 5b2e4f8e..468352c5 100644 --- a/views/site_files/text_editor.slim +++ b/views/site_files/text_editor.slim @@ -56,7 +56,7 @@ css: .row .span12 div id="editor" style="width: 100%; height: 600px; position: relative;" - #{@file_data} + == encoding_fix @file_data .row From 81cec7bbb40705bc2f93e94d103f6234425dbacf Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 25 Jul 2013 00:10:50 +0200 Subject: [PATCH 3/4] add favicon --- models/site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/site.rb b/models/site.rb index 06ce799f..a5836949 100644 --- a/models/site.rb +++ b/models/site.rb @@ -1,7 +1,7 @@ class Site < Sequel::Model # We might need to include fonts in here.. - VALID_MIME_TYPES = ['text/plain', 'text/html', 'text/css', 'application/javascript', 'image/png', 'image/jpeg', 'image/gif', 'image/svg+xml', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/octet-stream', 'text/csv', 'text/tsv', 'text/cache-manifest'] - VALID_EXTENSIONS = %w{ html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff json geojson csv tsv mf} + VALID_MIME_TYPES = ['text/plain', 'text/html', 'text/css', 'application/javascript', 'image/png', 'image/jpeg', 'image/gif', 'image/svg+xml', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/octet-stream', 'text/csv', 'text/tsv', 'text/cache-manifest', 'image/x-icon'] + VALID_EXTENSIONS = %w{ html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff json geojson csv tsv mf ico} #USERNAME_SHITLIST = %w{ payment secure login signin www ww web } # I thought they were funny personally, but everybody is freaking out so.. MAX_SPACE = (5242880*2) # 10MB MINIMUM_PASSWORD_LENGTH = 5 From b5ad4d6b137e1161e819405761f9227aa663a864 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 27 Jul 2013 01:54:24 +0200 Subject: [PATCH 4/4] fix typo --- views/site_files/upload.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/site_files/upload.slim b/views/site_files/upload.slim index 46be1bde..3af1ebe1 100644 --- a/views/site_files/upload.slim +++ b/views/site_files/upload.slim @@ -43,7 +43,7 @@ javascript: .row .span5.text-center - h5 NeoCities uses a drop and drop file upload. Simply take files and drop them from your computer on the white box (or click it) and they are uploaded. + h5 NeoCities uses a "drag and drop" file upload. Simply take files and drop them from your computer on the white box (or click it) and they are uploaded. div style="background-color: #FFFFFF;" form action="/site_files/upload" class="dropzone" id="uploads" input name="csrf_token" type="hidden" value="#{csrf_token}"