From 933fb9fcfd4b6819721090147f339bf958bf9bc2 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 1 Aug 2014 22:37:38 -0700 Subject: [PATCH] make editor theme stick, and get rid of slim --- Gemfile | 1 - Gemfile.lock | 5 - app.rb | 8 +- migrations/036_add_editor_theme.rb | 9 ++ views/layout.erb | 3 +- views/layout.slim | 55 ---------- views/site_files/text_editor.erb | 162 +++++++++++++++++++++++++++++ views/site_files/text_editor.slim | 127 ---------------------- 8 files changed, 180 insertions(+), 190 deletions(-) create mode 100644 migrations/036_add_editor_theme.rb delete mode 100644 views/layout.slim create mode 100644 views/site_files/text_editor.erb delete mode 100644 views/site_files/text_editor.slim diff --git a/Gemfile b/Gemfile index c6aa72d9..54dde2e8 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,6 @@ source 'https://rubygems.org' gem 'sinatra' gem 'redis' gem 'sequel', '4.8.0' -gem 'slim' gem 'bcrypt' gem 'sinatra-flash', require: 'sinatra/flash' gem 'sinatra-xsendfile', require: 'sinatra/xsendfile' diff --git a/Gemfile.lock b/Gemfile.lock index d9ee058e..60c6c663 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -167,11 +167,7 @@ GEM sinatra (>= 1.0.0) sinatra-xsendfile (0.4.2) sinatra (>= 0.9.1) - slim (2.0.2) - temple (~> 0.6.6) - tilt (>= 1.3.3, < 2.1) slop (3.5.0) - temple (0.6.7) tilt (1.4.1) timers (1.1.0) treetop (1.4.15) @@ -234,7 +230,6 @@ DEPENDENCIES sinatra sinatra-flash sinatra-xsendfile - slim stripe! tilt webmock diff --git a/app.rb b/app.rb index 4735405b..9bde856e 100644 --- a/app.rb +++ b/app.rb @@ -112,6 +112,12 @@ get '/site/:username' do |username| erb :'site', locals: {site: site, is_current_site: site == current_site} end +post '/site/:username/set_editor_theme' do + require_login + current_site.update editor_theme: params[:editor_theme] + 'ok' +end + post '/site/:username/comment' do |username| require_login @@ -641,7 +647,7 @@ get '/site_files/text_editor/:filename' do |filename| flash[:error] = 'We could not find the requested file.' redirect '/dashboard' end - slim :'site_files/text_editor', indent: false + erb :'site_files/text_editor' end post '/site_files/save/:filename' do |filename| diff --git a/migrations/036_add_editor_theme.rb b/migrations/036_add_editor_theme.rb new file mode 100644 index 00000000..3a158357 --- /dev/null +++ b/migrations/036_add_editor_theme.rb @@ -0,0 +1,9 @@ +Sequel.migration do + up { + DB.add_column :sites, :editor_theme, :text + } + + down { + DB.drop_column :sites, :editor_theme + } +end \ No newline at end of file diff --git a/views/layout.erb b/views/layout.erb index faa5abf0..012eca2a 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -39,6 +39,8 @@ + + @@ -50,7 +52,6 @@ <%== erb :'_footer', layout: false %> - diff --git a/views/layout.slim b/views/layout.slim deleted file mode 100644 index 9d0d9ca9..00000000 --- a/views/layout.slim +++ /dev/null @@ -1,55 +0,0 @@ -doctype html -html - head - meta http-equiv="Content-Type" content="text/html; charset=UTF-8" - - title Neocities #{@title.nil? ? '' : " - #{@title}"} - link href="/favicon.ico" rel="icon" type="image/x-icon" - link href="/css/bootstrap.min.css" rel="stylesheet" - link href="/css/bootstrap-responsive.min.css" rel="stylesheet" - link href="/css/font-awesome.min.css" rel="stylesheet" - link href="/css/styles.css" rel="stylesheet" - meta property="og:title" content="NeoCities" - meta property="og:description" content="NeoCities is the new Geocities. Create your own free home page, and do whatever you want with it." - meta name="csrf-token" content="#{csrf_token}" - script src="/assets/scripts/jquery-1.11.0.min.js" - link href="/assets/css/neo.css" rel="stylesheet" type="text/css" media="all" - script src="/assets/scripts/nav.min.js" - - body.interior - a id="top" - - == erb :'_header', layout: false - - .page - .container - - flash.keys.each do |key| - - next unless %i{success error}.include? key - div class="alert alert-#{key}" - button.close type="button" data-dismiss="alert" × - == flash[key] - == yield - - script src="/js/bootstrap.min.js" - - javascript: - !function(){ - var csrf_token = $('meta[name="csrf-token"]').attr('content'); - - $(document).ajaxSend(function(ev, jqxhr){ - jqxhr.setRequestHeader('X-CSRF-Token', csrf_token); - }); - }(); - - - javascript: - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-41925541-1', 'neocities.org'); - ga('send', 'pageview'); - - footer class="footer-Base" - == erb :'_footer', layout: false diff --git a/views/site_files/text_editor.erb b/views/site_files/text_editor.erb new file mode 100644 index 00000000..8cf5822d --- /dev/null +++ b/views/site_files/text_editor.erb @@ -0,0 +1,162 @@ + + +
+
+

Editing <%= params[:filename] %>

+
+
+ +
+
+
+

+ Theme: + +

+
+
+ +
+
+
<%==encoding_fix(@file_data) %> +
+
+
+ +
+ + + + + +
+ +
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/views/site_files/text_editor.slim b/views/site_files/text_editor.slim deleted file mode 100644 index 61ef0fc9..00000000 --- a/views/site_files/text_editor.slim +++ /dev/null @@ -1,127 +0,0 @@ -css: - #editor { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - } - .theme-Code{ - float:right; - position:relative; - top:-50px; - } - -.page - .content-Base - - h2 Editing #{params[:filename]} - - .theme-Code - p style="display:inline-block; margin-right:10px" Theme: - select id="theme" size="1" onchange="setTheme();" onkeyup="setTheme();" - optgroup label="Bright" - option value="ace/theme/chrome" Chrome - option value="ace/theme/clouds" Clouds - option value="ace/theme/crimson_editor" Crimson Editor - option value="ace/theme/dawn" Dawn - option value="ace/theme/dreamweaver" Dreamweaver - option value="ace/theme/eclipse" Eclipse - option value="ace/theme/github" GitHub - option value="ace/theme/solarized_light" Solarized Light - option value="ace/theme/textmate" TextMate - option value="ace/theme/tomorrow" Tomorrow - option value="ace/theme/xcode" XCode - optgroup label="Dark" - option value="ace/theme/ambiance" Ambiance - option value="ace/theme/chaos" Chaos - option value="ace/theme/clouds_midnight" Clouds Midnight - option value="ace/theme/cobalt" Cobalt - option value="ace/theme/idle_fingers" idleFingers - option value="ace/theme/kr_theme" krTheme - option value="ace/theme/merbivore" Merbivore - option value="ace/theme/merbivore_soft" Merbivore Soft - option value="ace/theme/mono_industrial" Mono Industrial - option value="ace/theme/monokai" Monokai - option value="ace/theme/pastel_on_dark" Pastel on dark - option value="ace/theme/solarized_dark" selected="selected" Solarized Dark - option value="ace/theme/terminal" Terminal - option value="ace/theme/tomorrow_night" Tomorrow Night - option value="ace/theme/tomorrow_night_blue" Tomorrow Night Blue - option value="ace/theme/tomorrow_night_bright" Tomorrow Night Bright - option value="ace/theme/tomorrow_night_eighties" Tomorrow Night 80s - option value="ace/theme/twilight" Twilight - option value="ace/theme/vibrant_ink" Vibrant Ink - -
#{{encoding_fix(@file_data)}}
- - .row - .col.col-33.txt-Center style="margin-bottom:10px" - a.btn-Action href="/dashboard"   Finish Without Saving - - .col.col-33.txt-Center style="margin-bottom:10px" - a.btn-Action href="#" onclick="saveTextFile(false); return false"   Save Changes - - .col.col-33.txt-Center - a.btn-Action href="#" onclick="saveTextFile(true); return false"   Save and Finish - - .row style="margin-top: 20px" - .span6.offset3.text-center - div id="editorUpdates" class="alert alert-success hidden" - span - - script src="/js/ace/ace.js" type="text/javascript" charset="utf-8" - javascript: - - function setTheme(name) { - editor.setTheme($('#theme').val()); - } - - function saveTextFile(quit) { - /* - $.post('/site_files/save/#{params[:filename]}', editor.getValue(), function(resp) { - if(resp == 'ok') { - $('#editorUpdates span').text('Your file has been saved.'); - $('#editorUpdates').removeClass('hidden'); - } - }); - */ - - $.ajax({ - url: '/site_files/save/#{params[:filename]}', - data: editor.getValue(), - processData: false, - contentType: false, - type: 'POST', - success: function(response){ - if(response == 'ok') { - if(quit === true) { - window.location = '/dashboard'; - } - $('#editorUpdates span').html('  Your file has been saved.'); - setTimeout(function() { - $('#editorUpdates').fadeOut(); //.addClass('hidden'); - }, 2000); - - } else { - $('#editorUpdates span').text(response); - } - $('#editorUpdates').fadeIn(); - $('#editorUpdates').removeClass('hidden'); - - } - }); - } - - var editor = {}; - - $(document).ready(function() { - editor = ace.edit("editor"); - setTheme(); - editor.getSession().setMode("ace/mode/html"); - editor.getSession().setTabSize(2); - editor.getSession().setUseWrapMode(true); - editor.setFontSize(14); - editor.setShowPrintMargin(false); - - }); \ No newline at end of file