Merge branch 'master' into customdomains

This commit is contained in:
Kyle Drake 2013-07-27 06:08:09 +02:00
commit dc0a88b541
4 changed files with 15 additions and 5 deletions

12
app.rb
View file

@ -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)
@ -605,3 +606,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

View file

@ -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

View file

@ -56,7 +56,7 @@ css:
.row
.span12
div id="editor" style="width: 100%; height: 600px; position: relative;"
#{@file_data}
== encoding_fix @file_data
.row

View file

@ -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}"