# HG changeset patch # User nanaya # Date 1441479172 -32400 # Node ID 851432f21603f51bb50a0ec278c2942f7b474edd # Parent 26f8c634052c3fba9cb96a4164b5fee16a4b1830 Nope, failing at redesigning. diff -r 26f8c634052c -r 851432f21603 Gemfile --- a/Gemfile Sat Jun 27 14:46:01 2015 +0900 +++ b/Gemfile Sun Sep 06 03:52:52 2015 +0900 @@ -4,6 +4,12 @@ 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" diff -r 26f8c634052c -r 851432f21603 Gemfile.lock --- a/Gemfile.lock Sat Jun 27 14:46:01 2015 +0900 +++ b/Gemfile.lock Sun Sep 06 03:52:52 2015 +0900 @@ -1,45 +1,49 @@ GEM remote: https://rubygems.org/ + remote: https://rails-assets.org/ specs: - actionmailer (4.2.1) - actionpack (= 4.2.1) - actionview (= 4.2.1) - activejob (= 4.2.1) + actionmailer (4.2.4) + actionpack (= 4.2.4) + actionview (= 4.2.4) + activejob (= 4.2.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.1) - actionview (= 4.2.1) - activesupport (= 4.2.1) + actionpack (4.2.4) + actionview (= 4.2.4) + activesupport (= 4.2.4) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.1) - activesupport (= 4.2.1) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.4) + activesupport (= 4.2.4) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.1) - activesupport (= 4.2.1) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.4) + activesupport (= 4.2.4) globalid (>= 0.3.0) - activemodel (4.2.1) - activesupport (= 4.2.1) + activemodel (4.2.4) + activesupport (= 4.2.4) builder (~> 3.1) - activerecord (4.2.1) - activemodel (= 4.2.1) - activesupport (= 4.2.1) + activerecord (4.2.4) + activemodel (= 4.2.4) + activesupport (= 4.2.4) arel (~> 6.0) - activesupport (4.2.1) + activesupport (4.2.4) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (6.0.0) - autoprefixer-rails (5.2.0) + arel (6.0.3) + autoprefixer-rails (6.0.0) execjs json + bootstrap-sass (3.3.5.1) + autoprefixer-rails (>= 5.0.0.1) + sass (>= 3.3.0) builder (3.2.2) coffee-rails (4.1.0) coffee-script (>= 2.2.0) @@ -49,75 +53,77 @@ execjs coffee-script-source (1.9.1.1) erubis (2.7.0) - execjs (2.5.2) - globalid (0.3.5) + execjs (2.6.0) + globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) - jquery-rails (4.0.3) + jquery-rails (4.0.5) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) - loofah (2.0.2) + loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.6.1) mini_portile (0.6.2) - minitest (5.7.0) - newrelic_rpm (3.12.0.288) + minitest (5.8.0) + newrelic_rpm (3.13.0.299) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) - pg (0.18.2) + pg (0.18.3) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.1) + rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.1) - actionmailer (= 4.2.1) - actionpack (= 4.2.1) - actionview (= 4.2.1) - activejob (= 4.2.1) - activemodel (= 4.2.1) - activerecord (= 4.2.1) - activesupport (= 4.2.1) + rails (4.2.4) + actionmailer (= 4.2.4) + actionpack (= 4.2.4) + actionview (= 4.2.4) + activejob (= 4.2.4) + activemodel (= 4.2.4) + activerecord (= 4.2.4) + activesupport (= 4.2.4) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.1) + 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.6) + rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.2) loofah (~> 2.0) - railties (4.2.1) - actionpack (= 4.2.1) - activesupport (= 4.2.1) + railties (4.2.4) + actionpack (= 4.2.4) + activesupport (= 4.2.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) - sass (3.4.14) - sass-rails (5.0.3) + sass (3.4.18) + 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) - sprockets (3.2.0) + tilt (>= 1.1, < 3) + sprockets (3.3.4) rack (~> 1.0) - sprockets-rails (2.3.1) + sprockets-rails (2.3.2) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) thor (0.19.1) thread_safe (0.3.5) - tilt (1.4.1) + tilt (2.0.1) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.1) + uglifier (2.7.2) execjs (>= 0.3.0) json (>= 1.8.0) @@ -127,6 +133,7 @@ DEPENDENCIES activerecord-jdbcpostgresql-adapter autoprefixer-rails + bootstrap-sass coffee-rails (~> 4.1.0) jquery-rails jruby-openssl @@ -134,9 +141,11 @@ pg quiet_assets rails (~> 4.2.0) + rails-assets-commonmark! + rails-assets-highlightjs! sass-rails (~> 5.0) therubyrhino uglifier (>= 1.3.0) BUNDLED WITH - 1.10.3 + 1.10.6 diff -r 26f8c634052c -r 851432f21603 app/assets/javascripts/application.coffee --- a/app/assets/javascripts/application.coffee Sat Jun 27 14:46:01 2015 +0900 +++ b/app/assets/javascripts/application.coffee Sun Sep 06 03:52:52 2015 +0900 @@ -1,4 +1,58 @@ #= require jquery -#= require jquery_ujs +#= 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() + -#= require new_paste +$(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 26f8c634052c -r 851432f21603 app/assets/javascripts/form_clear_main.coffee --- a/app/assets/javascripts/form_clear_main.coffee Sat Jun 27 14:46:01 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -$(document).on "click", ".js-form-main-clear", (e) -> - e.preventDefault() - $(e.target).parents("form").find(".js-form-main") - .val("") - .focus() diff -r 26f8c634052c -r 851432f21603 app/assets/javascripts/new_paste.coffee --- a/app/assets/javascripts/new_paste.coffee Sat Jun 27 14:46:01 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -$(document).on "click", "#reset_paste", (e) -> - e.preventDefault() - $("#paste_paste") - .val("") - .focus() diff -r 26f8c634052c -r 851432f21603 app/assets/javascripts/show_paste.coffee --- a/app/assets/javascripts/show_paste.coffee Sat Jun 27 14:46:01 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -$(document).ready -> - $("[id^=L]").click (e) -> - console.log $(e.target).attr("id") - document.location = "##{$(e.target).attr("id")}" diff -r 26f8c634052c -r 851432f21603 app/assets/stylesheets/application.scss --- a/app/assets/stylesheets/application.scss Sat Jun 27 14:46:01 2015 +0900 +++ b/app/assets/stylesheets/application.scss Sun Sep 06 03:52:52 2015 +0900 @@ -1,224 +1,35 @@ -$spacing: 10px; -$screen-sm: 600px; - -$bg: #fff; -$gray: #eee; -$gray-dark: darken($gray, 20%); -$danger: scale-color(#f00, $lightness: 90%); -$danger-dark: darken($danger, 60%); -$info: scale-color(#0f0, $lightness: 90%); -$info-dark: darken($info, 60%); -$primary: scale-color(#06f, $lightness: 90%); - -$monospace: Consolas, monospace; - -*, ::before, ::after { - position: relative; - box-sizing: border-box; -} - -body, button, input, textarea { - font-family: Segoe UI, Helvetica Neue, Helvetica, Arial, sans-serif; - font-size: 12px; -} - -p, h1 { - margin: 0px; -} - -html { - height: 100%; -} - -body { - height: 100%; - margin: 0px; - display: flex; - flex-direction: column; -} +@import "bootstrap"; +@import "highlightjs"; .input-url1 { display: none !important; } -.monospaced { - font-family: $monospace; -} - -.header { - background-color: $gray; - display: flex; - justify-content: space-between; - align-items: center; - padding: $spacing; - flex: none; -} - -.main { - display: flex; - flex: 1 0 auto; - padding: $spacing; - flex-direction: column; +.paste-paste { + resize: none; + font-family: $font-family-monospace; } -.main-form { - flex: 1; - display: flex; - flex-direction: column; -} - -.main-textarea-container { - flex: 1 0 auto; - display: flex; -} +.paste-show { + padding: $grid-gutter-width/2; + margin-bottom: $grid-gutter-width/2; -.main-textarea { - width: 100%; -} - -.settings { - display: flex; - margin: $spacing (-$spacing/2) 0px; -} + 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; -.settings-item { - display: flex; - flex-direction: column; - flex: 1; - margin: 0px $spacing/2; - - @media (min-width: $screen-sm) { - flex: none; + &__content { + border: none; + background-color: #fff; + padding: 0px; + margin: 0px; } } -.settings-label { - margin-bottom: $spacing/2; -} - -.actions { - display: flex; -} - -.action { - flex: 1; - @media (min-width: $screen-sm) { - flex: none; - } - margin: 0px $spacing/2; -} - -.alert { - padding: $spacing; - flex: none; -} - -.alert-danger { - background-color: $danger; -} - -.alert-info { - background-color: $info; -} - -.field_with_errors { - display: flex; - width: 100%; - border: 1px solid $danger-dark; -} - -.paste-content { - flex: 1 0 auto; - display: flex; - flex-direction: column; -} - -.paste-nav { - display: flex; - justify-content: space-between; - margin: 0px (-$spacing/2); -} - -.paste-nav-item { - flex: 1 1 0px; - text-align: center; - border: 1px solid $gray-dark; - margin: 0px $spacing/2 $spacing; - padding: $spacing; - - &:hover { - background-color: $gray-dark; - } -} - -.active { - background-color: $gray; +.zp-hl { + background-color: #fff; + padding: 0px; } -.paste-plain { - background-color: $gray; - margin: 0px; - border: 1px solid $gray-dark; - flex: none; -} - -.line { - background-color: $bg; - flex: 1; -} - -.paste-nav--bottom { - margin-top: $spacing; - margin-bottom: 0px; -} - -.settings-item--inline { - flex-direction: row; - flex: 1; -} - -.action--horizontal-minimum { - margin: 0px; - flex: none; +.zp-header { + margin-top: 0px; } - -.settings-group { - display: flex; - flex-direction: column; - width: 100%; - - @media (min-width: $screen-sm) { - flex-direction: row; - justify-content: space-between; - } -} - -.btn { - box-shadow: 0px -2px 0px rgba(0, 0, 0, 0.1) inset; - border: 0px; - background-color: $gray; - cursor: pointer; - padding: $spacing ($spacing*2); -} - -@mixin btn-color($color) { - background-color: $color; - - &:hover { - background-color: darken($color, 10%); - } - - &:focus { - background-color: darken($color, 20%); - } -} - -.btn--primary { - @include btn-color($primary); -} - -.btn--danger { - @include btn-color($danger); -} - -.btn--min-width { - flex: none; -} diff -r 26f8c634052c -r 851432f21603 app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb Sat Jun 27 14:46:01 2015 +0900 +++ b/app/helpers/application_helper.rb Sun Sep 06 03:52:52 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 26f8c634052c -r 851432f21603 app/views/layouts/application.html.erb --- a/app/views/layouts/application.html.erb Sat Jun 27 14:46:01 2015 +0900 +++ b/app/views/layouts/application.html.erb Sun Sep 06 03:52:52 2015 +0900 @@ -3,28 +3,44 @@ <%= html_title %> - - <%= stylesheet_link_tag "application", :media => "all" %> + + <%= stylesheet_link_tag "application", :media => "all" %> - <%= yield(:before_page_header) %> -
-

- <%= link_to "Zeropaste", root_path %> / <%= content_for :title %> -

+
+ + - <%= render "layouts/alerts" %> +
+
+

<%= content_for :title %>

+
-
+ <%= render "layouts/alerts" %> + <%= yield %> -
+
<%= javascript_include_tag "application" %> diff -r 26f8c634052c -r 851432f21603 app/views/pastes/_form.html.erb --- a/app/views/pastes/_form.html.erb Sat Jun 27 14:46:01 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -<%= form_for @paste, :html => { :class => "main-form" } do |f| %> - <%= render "shared/filter_spam" %> -
- <%= f.text_area :paste, :rows => 10, :autofocus => true, :class => "main-textarea monospaced" %> -
- -
- -
- -
- <%= f.label :key, t(".deletion_key"), :class => "settings-label" %> - <%= f.text_field :key %> -
- -
-
<%= t(".privacy.label") %>
- - <% paste_privacy_options.each do |label, value| %> - - <% end %> -
- -
- -
- - <%= f.button :class => "action btn btn--primary" %> - - <%= button_tag t(".clear"), :type => "button", :class => "action btn btn--danger" %> - -
- -
-<% end %> diff -r 26f8c634052c -r 851432f21603 app/views/pastes/new.html.erb --- a/app/views/pastes/new.html.erb Sat Jun 27 14:46:01 2015 +0900 +++ b/app/views/pastes/new.html.erb Sun Sep 06 03:52:52 2015 +0900 @@ -1,3 +1,38 @@ -<% provide :title, 'New Paste' %> +<% provide :title, t(".title") %> +<%= form_for @paste do |f| %> + <%= render "shared/filter_spam" %> + +
+ <%= f.text_area :paste, :autofocus => true, :class => "form-control paste-paste js-paste-paste", :rows => 20 %> +
+ +
+
+ <%= f.label :key, t(".deletion_key"), :class => "col-sm-2 control-label" %> +
+ <%= f.text_field :key, :class => "form-control" %> +
+
+ +
+ -<%= render 'form' %> +
+ <% paste_privacy_options.each do |label, value| %> +
+ +
+ <% end %> +
+
+ +
+ <%= f.button :class => "btn btn-primary" %> + + <%= link_to t(".clear"), "#", :class => "btn btn-danger js-paste-clear" %> +
+
+<% end %> diff -r 26f8c634052c -r 851432f21603 app/views/pastes/show.html.erb --- a/app/views/pastes/show.html.erb Sat Jun 27 14:46:01 2015 +0900 +++ b/app/views/pastes/show.html.erb Sun Sep 06 03:52:52 2015 +0900 @@ -1,35 +1,68 @@ <% provide :title, "Paste ##{@paste.id}" %> -
-
- <%= link_to 'Plain', '#pl', :class => "paste-nav-item active" %> - <%= link_to 'Highlight', '#hl', :class => "paste-nav-item" %> - <%= link_to 'Markdown', '#md', :class => "paste-nav-item" %> -
- - <% lines = @paste.paste.split("\n") %> - <%# list number contains + "." + <2.5 * spaces (approx)> %> -
    - <% lines.each.with_index(1) do |line, i| %> -
  1. - <%= line %> +
    +
+ +
+ +
+
+
+
<%= @paste.paste %>
+
+ +
+
+
+ +
+
+
+
+
+ +
+ <%= form_for @paste, :method => :delete, :authenticity_token => false do |f| %> +
+
+ <%= f.text_field :key, + :value => nil, + :placeholder => t("pastes.new.deletion_key"), + :autofocus => f.object.errors.any?, + :class => "form-control" + %> + + + <%= f.button t(".delete"), :class => "btn btn-danger" %> + +
+
+ <% end %>
-
- <%= form_for @paste, :method => :delete, :authenticity_token => false, :html => { :class => "settings-item settings-item--inline" } do |f| %> - - <%= f.text_field :key, :value => nil, :placeholder => 'Deletion key', :autofocus => f.object.errors.any?, :class => "main-textarea" %> - - <%= f.button 'Delete this paste', :class => 'btn btn--danger btn--min-width' %> - <% end %> - -
- -
- <%= link_to 'Raw', paste_path(@paste, :txt), :class => "paste-nav-item" %> - <%= link_to 'Derive', root_path(:base => @paste), :class => "paste-nav-item" %> - <%= link_to 'More Paste', root_path, :class => "paste-nav-item" %> -
+
+ diff -r 26f8c634052c -r 851432f21603 config/application.rb --- a/config/application.rb Sat Jun 27 14:46:01 2015 +0900 +++ b/config/application.rb Sun Sep 06 03:52:52 2015 +0900 @@ -68,5 +68,7 @@ # No need to initialize application when precompiling assets config.assets.initialize_on_precompile = false + + config.action_view.field_error_proc = proc { |html| html } end end diff -r 26f8c634052c -r 851432f21603 config/locales/en.yml --- a/config/locales/en.yml Sat Jun 27 14:46:01 2015 +0900 +++ b/config/locales/en.yml Sun Sep 06 03:52:52 2015 +0900 @@ -3,10 +3,11 @@ en: pastes: - form: + new: clear: Clear deletion_key: Deletion key privacy: label: Privacy private: Private public: Public + title: New Paste diff -r 26f8c634052c -r 851432f21603 vendor/assets/javascripts/jquery.autosize.js --- a/vendor/assets/javascripts/jquery.autosize.js Sat Jun 27 14:46:01 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -// Autosize 1.13 - jQuery plugin for textareas -// (c) 2012 Jack Moore - jacklmoore.com -// license: www.opensource.org/licenses/mit-license.php - -(function ($) { - var - defaults = { - className: 'autosizejs', - append: "", - callback: false - }, - hidden = 'hidden', - borderBox = 'border-box', - lineHeight = 'lineHeight', - copy = '