# HG changeset patch # User nanaya # Date 1441479214 -32400 # Node ID 4bf12ecde0ee43e7794f61c169da2a11548bc27d # Parent 851432f21603f51bb50a0ec278c2942f7b474edd# Parent 5fb3288960cab851e6224adaeae2871e2012ceed Back to default. diff -r 5fb3288960ca -r 4bf12ecde0ee Gemfile --- a/Gemfile Wed Sep 02 17:12:13 2015 +0900 +++ b/Gemfile Sun Sep 06 03:53:34 2015 +0900 @@ -3,6 +3,13 @@ gem "rails", "~> 4.2.0" gem "jquery-rails" gem "coffee-rails", "~> 4.1.0" # Rails 4.2 default +gem "autoprefixer-rails" +gem "bootstrap-sass" + +source "https://rails-assets.org" do + gem "rails-assets-highlightjs" + gem "rails-assets-commonmark" +end # Bundle edge Rails instead: # gem "rails", :git => "git://github.com/rails/rails.git" @@ -14,7 +21,6 @@ gem "sass-rails", "~> 5.0" # Rails 4.2 default gem "uglifier", ">= 1.3.0" # Rails 4.2 default -gem "bootstrap-sass" gem "therubyrhino", :platforms => :jruby diff -r 5fb3288960ca -r 4bf12ecde0ee Gemfile.lock --- a/Gemfile.lock Wed Sep 02 17:12:13 2015 +0900 +++ b/Gemfile.lock Sun Sep 06 03:53:34 2015 +0900 @@ -1,5 +1,6 @@ GEM remote: https://rubygems.org/ + remote: https://rails-assets.org/ specs: actionmailer (4.2.4) actionpack (= 4.2.4) @@ -30,11 +31,6 @@ activemodel (= 4.2.4) activesupport (= 4.2.4) arel (~> 6.0) - activerecord-jdbc-adapter (1.3.17) - activerecord (>= 2.2) - activerecord-jdbcpostgresql-adapter (1.3.17) - activerecord-jdbc-adapter (~> 1.3.17) - jdbc-postgres (>= 9.1) activesupport (4.2.4) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) @@ -42,7 +38,7 @@ thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) - autoprefixer-rails (5.2.1.3) + autoprefixer-rails (6.0.0) execjs json bootstrap-sass (3.3.5.1) @@ -61,14 +57,11 @@ globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) - jdbc-postgres (9.4.1200) jquery-rails (4.0.5) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jruby-openssl (0.9.11-java) json (1.8.3) - json (1.8.3-java) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) @@ -79,8 +72,7 @@ newrelic_rpm (3.13.0.299) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) - nokogiri (1.6.6.2-java) - pg (0.18.2) + pg (0.18.3) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.4) @@ -97,6 +89,8 @@ bundler (>= 1.3.0, < 2.0) railties (= 4.2.4) sprockets-rails + rails-assets-commonmark (0.22.0) + rails-assets-highlightjs (8.7.0) rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) rails-dom-testing (1.0.7) @@ -112,25 +106,21 @@ thor (>= 0.18.1, < 2.0) rake (10.4.2) sass (3.4.18) - sass-rails (5.0.3) + sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) - tilt (~> 1.1) + tilt (>= 1.1, < 3) sprockets (3.3.4) rack (~> 1.0) sprockets-rails (2.3.2) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - therubyrhino (2.0.4) - therubyrhino_jar (>= 1.7.3) - therubyrhino_jar (1.7.6) thor (0.19.1) thread_safe (0.3.5) - thread_safe (0.3.5-java) - tilt (1.4.1) + tilt (2.0.1) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.7.2) @@ -138,11 +128,11 @@ json (>= 1.8.0) PLATFORMS - java ruby DEPENDENCIES activerecord-jdbcpostgresql-adapter + autoprefixer-rails bootstrap-sass coffee-rails (~> 4.1.0) jquery-rails @@ -151,6 +141,8 @@ pg quiet_assets rails (~> 4.2.0) + rails-assets-commonmark! + rails-assets-highlightjs! sass-rails (~> 5.0) therubyrhino uglifier (>= 1.3.0) diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/application.coffee --- a/app/assets/javascripts/application.coffee Wed Sep 02 17:12:13 2015 +0900 +++ b/app/assets/javascripts/application.coffee Sun Sep 06 03:53:34 2015 +0900 @@ -1,5 +1,58 @@ -#= require jquery_ujs -#= require bootstrap/tab -#= require bootstrap/button -#= require bootstrap/dropdown -#= require boot +#= require jquery +#= require bootstrap +#= require highlightjs +#= require commonmark + +$(document).on "click", ".js-paste-clear", (e) -> + e.preventDefault() + $(".js-paste-paste") + .val("") + .focus() + + +pasteText = -> + $(".js-paste-pl").text() + + +setHash = (newLocation = window.location.pathname) -> + return unless history.replaceState + + newLocation ||= window.location.pathname + history.replaceState null, "", newLocation + + +$(document).on "click", ".js-show-tab-pl", -> + setHash() + + +$(document).on "click", ".js-show-tab-hl", -> + setHash "#hl" + $hlBox = $(".js-paste-hl") + return if $hlBox.data("processed") + + $hlBox.text pasteText() + + highlight = -> hljs.highlightBlock($hlBox[0]) + setTimeout highlight, 0 + + $hlBox.data "processed", true + + +$(document).on "click", ".js-show-tab-md", -> + setHash "#md" + $mdBox = $(".js-paste-md") + return if $mdBox.data("processed") + + reader = new commonmark.Parser + writer = new commonmark.HtmlRenderer(safe: true) + parsed = reader.parse pasteText() + + $mdBox.html writer.render(parsed) + $mdBox.find("a").attr("rel", "nofollow") + $mdBox.data "processed", true + +$(document).on "ready", -> + return if $(".js-showing-paste").length < 1 + + format = window.location.hash.slice(1) + $(".js-show-tab-#{format}").click() diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/autosize_box_fix.coffee --- a/app/assets/javascripts/autosize_box_fix.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -$.autosize_box_fix = (elem) -> - elem.css 'box-sizing', '' - elem.css '-webkit-box-sizing', '' - elem.css '-moz-box-sizing', '' diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/boot.coffee --- a/app/assets/javascripts/boot.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#= require zp.init -#= require zp.formatter -#= require zp.hash_magic -#= require zp.new -$(document).ready -> - zp.formatter.init() - zp.hash_magic.init() - zp.new.init() diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/config/highlight.coffee --- a/app/assets/javascripts/config/highlight.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -#= require highlightjs diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/config/markdown.coffee --- a/app/assets/javascripts/config/markdown.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -#= require markdown diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/config/marked.coffee --- a/app/assets/javascripts/config/marked.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -#= require marked -marked.setOptions - gfm: true - pedantic: true - sanitize: true diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/config/prettify.coffee --- a/app/assets/javascripts/config/prettify.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -#= require prettify diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/zp.clean_notice.coffee --- a/app/assets/javascripts/zp.clean_notice.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -window.zp.cleanNotice = - init: -> - if (history.replaceState) - queryString = "?#{window.location.search.slice(1).replace(/(^|&)notice=[^&]*(&?)/, "$2")}" - newPath = window.location.pathname - newPath += queryString if queryString != "?" - newPath += window.location.hash - history.replaceState null, "", newPath diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/zp.formatter.coffee --- a/app/assets/javascripts/zp.formatter.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#= require config/marked -#= require config/prettify -window.zp.formatter = - raw: -> $("#pl pre").text() - links: -> $("#paste-mode a") - current: -> $("#paste-mode .active a").attr("href").slice(1) - markdown: -> - $("#md div") - .html(marked @raw()) - .find("pre").addClass "prettyprint" - .end() - .find("a").prop "rel", "nofollow" - highlight: -> - $("#hl pre").text @raw() - prettyPrint() - init: -> - @markdown() - @highlight() diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/zp.hash_magic.coffee --- a/app/assets/javascripts/zp.hash_magic.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#= require zp.formatter -window.zp.hash_magic = - load_hash: -> - format = window.location.hash.slice(1) - tab_link = (fmt) -> zp.formatter.links().filter("[href='##{fmt}']") - - format = "pl" unless tab_link(format).length - tab_link(format).click() - - set_hash: (e) -> - format = zp.formatter.current() - newpath = window.location.pathname - newpath += "##{format}" if (format != "pl") - history.replaceState null, "", newpath - - init: -> - return unless $("#paste").length - @load_hash() - if (history.replaceState) - @set_hash() - zp.formatter.links().on("shown.bs.tab", this.set_hash) diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/zp.init.coffee --- a/app/assets/javascripts/zp.init.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -window.zp = {} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/javascripts/zp.new.coffee --- a/app/assets/javascripts/zp.new.coffee Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#= require jquery.autosize -#= require autosize_box_fix -window.zp.new = - input: -> $("#paste_paste") - - clear: (e) -> - e.preventDefault() - @input().val("").focus() - - init: -> - return unless @input().length - - $(document).on "click", "#reset_paste", $.proxy(@clear, this) - @input().autosize className: "mirrored_text form-control", append: "\n" - $.autosize_box_fix $(".mirrored_text") - @input().focus() diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/alert.scss --- a/app/assets/stylesheets/alert.scss Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -.alert { - margin-top: 20px; -} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/app_bootstrap.scss --- a/app/assets/stylesheets/app_bootstrap.scss Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -@import 'bootstrap'; -@import 'sticky_footer'; - -// Rails support. -.field_with_errors { - @extend .has-error; -} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/application.scss --- a/app/assets/stylesheets/application.scss Wed Sep 02 17:12:13 2015 +0900 +++ b/app/assets/stylesheets/application.scss Sun Sep 06 03:53:34 2015 +0900 @@ -1,7 +1,35 @@ -@import "app_bootstrap"; -@import "bootstrap-prettify"; +@import "bootstrap"; +@import "highlightjs"; + +.input-url1 { display: none !important; } + +.paste-paste { + resize: none; + font-family: $font-family-monospace; +} + +.paste-show { + padding: $grid-gutter-width/2; + margin-bottom: $grid-gutter-width/2; -@import "alert"; -@import "pastes"; -@import "sticky_footer"; -@import "tabs"; + border-width: 0px 1px 1px 1px; + border-style: solid; + border-color: $nav-tabs-active-link-hover-border-color; + border-radius: 0px 0px $border-radius-base $border-radius-base; + + &__content { + border: none; + background-color: #fff; + padding: 0px; + margin: 0px; + } +} + +.zp-hl { + background-color: #fff; + padding: 0px; +} + +.zp-header { + margin-top: 0px; +} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/pastes.scss --- a/app/assets/stylesheets/pastes.scss Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -textarea#paste_paste, .mirrored_text { - font-family: Monaco, Menlo, Consolas, "Courier New", monospace; - resize: none; - -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ - -moz-box-sizing: border-box; /* Firefox, other Gecko */ - box-sizing: border-box; /* Opera/IE 8+ */ -} - -#pl > pre { - word-break: normal; -} - -#paste-show > div, -#paste-show > ul, -.edit_paste { - margin-bottom: 20px; -} - -#paste_key { - border-radius: 4px 0 0 4px; -} - -.input-url1 { - display: none; -} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/sticky_footer.scss --- a/app/assets/stylesheets/sticky_footer.scss Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* Sticky footer styles --------------------------------------------------- */ - -html, -body { - height: 100%; - /* The html and body elements cannot have any padding or margin. */ -} - -/* Wrapper for page content to push down footer */ -#wrap { - min-height: 100%; - height: auto !important; - height: 100%; - /* Negative indent footer by its height */ - margin: 0 auto -60px; - /* Pad bottom by footer height + 10 */ - padding: 0 0 70px; -} - -/* Set the fixed height of the footer here */ -#footer { - height: 60px; - background-color: #f5f5f5; -} - - -/* Custom page CSS --------------------------------------------------- */ -/* Not required for template or sticky footer method. */ - -.container .credit { - margin: 20px 0; -} diff -r 5fb3288960ca -r 4bf12ecde0ee app/assets/stylesheets/tabs.scss --- a/app/assets/stylesheets/tabs.scss Wed Sep 02 17:12:13 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#md { - // copypasta from bootstrap's variables.scss - $baseFontSize_orig: 14px; - $baseLineHeight_orig: 20px; - - // reduce for paste show - $baseFontSize: $baseFontSize_orig * 0.8; - $baseLineHeight: $baseLineHeight_orig * 0.8; - - .well { - background-color: darken(white, 2%); - } - - p { - margin: 0; - } - - // copypasta from bootstrap's type.scss - h1, - h2, - h3 { line-height: $baseLineHeight * 2; } - - // more copypasta from bootstrap's type.scss - h1 { font-size: $baseFontSize * 2.75; } - h2 { font-size: $baseFontSize * 2.25; } - h3 { font-size: $baseFontSize * 1.75; } - h4 { font-size: $baseFontSize * 1.25; } - h5 { font-size: $baseFontSize; } - h6 { font-size: $baseFontSize * 0.85; } -} diff -r 5fb3288960ca -r 4bf12ecde0ee app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb Wed Sep 02 17:12:13 2015 +0900 +++ b/app/helpers/application_helper.rb Sun Sep 06 03:53:34 2015 +0900 @@ -7,4 +7,8 @@ base_title end end + + def error_class(object, attribute) + "has-error" if object.errors.include? attribute + end end diff -r 5fb3288960ca -r 4bf12ecde0ee app/helpers/pastes_helper.rb --- a/app/helpers/pastes_helper.rb Wed Sep 02 17:12:13 2015 +0900 +++ b/app/helpers/pastes_helper.rb Sun Sep 06 03:53:34 2015 +0900 @@ -11,4 +11,8 @@ end end end + + def paste_privacy_options + { "public" => "0", "private" => "1" } + end end diff -r 5fb3288960ca -r 4bf12ecde0ee app/models/paste.rb --- a/app/models/paste.rb Wed Sep 02 17:12:13 2015 +0900 +++ b/app/models/paste.rb Sun Sep 06 03:53:34 2015 +0900 @@ -1,5 +1,7 @@ class Paste < ActiveRecord::Base attr_accessor :is_private + after_initialize :set_privacy, :if => :new_record? + before_validation :paste_limit before_validation :convert_newlines before_validation :set_paste_hash @@ -83,6 +85,10 @@ errors.add :base, :limit if ip_post_recent_count > 100 end + def set_privacy + self.is_private ||= "0" + end + def self.fix_all stats = Hash.new(0) all.find_each do |p| diff -r 5fb3288960ca -r 4bf12ecde0ee app/views/layouts/_alerts.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/layouts/_alerts.html.erb Sun Sep 06 03:53:34 2015 +0900 @@ -0,0 +1,13 @@ +<% if notice %> +
+ Info: + <%= notice %> +
+<% end %> + +<% if alert %> +
+ Error: + <%= alert %> +
+<% end %> diff -r 5fb3288960ca -r 4bf12ecde0ee app/views/layouts/application.html.erb --- a/app/views/layouts/application.html.erb Wed Sep 02 17:12:13 2015 +0900 +++ b/app/views/layouts/application.html.erb Sun Sep 06 03:53:34 2015 +0900 @@ -3,28 +3,44 @@ <%= html_title %> - - <%= stylesheet_link_tag "application", :media => "all" %> + + <%= stylesheet_link_tag "application", :media => "all" %> - -
-
- <%= yield %> -
-
- -