Commit 7b1584ad by tady

google code pretty

parent 7024ba85
...@@ -49,7 +49,8 @@ gem 'devise' ...@@ -49,7 +49,8 @@ gem 'devise'
gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
# Markdown # Markdown
gem 'redcarpet' gem 'redcarpet', :git => 'git://github.com/vmg/redcarpet.git',
:branch => "master"
# Syntax Highlight # Syntax Highlight
gem 'coderay' gem 'coderay'
......
GIT
remote: git://github.com/vmg/redcarpet.git
revision: 52c5fa3c5753d2125e827f235cdf4cb730484902
branch: master
specs:
redcarpet (3.0.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -114,7 +121,6 @@ GEM ...@@ -114,7 +121,6 @@ GEM
rake (10.1.0) rake (10.1.0)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
redcarpet (3.0.0)
sass (3.2.12) sass (3.2.12)
sass-rails (4.0.1) sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
...@@ -165,7 +171,7 @@ DEPENDENCIES ...@@ -165,7 +171,7 @@ DEPENDENCIES
pg pg
rails (~> 4.0.2) rails (~> 4.0.2)
rails_12factor rails_12factor
redcarpet redcarpet!
sass-rails (~> 4.0.0) sass-rails (~> 4.0.0)
sdoc sdoc
sqlite3 sqlite3
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
$ ->
# search form animation
$('#app-search-form input')
.on 'focus', ->
$(this).parents('#app-search-form').animate({width: '400px'})
.on 'blur', ->
$(this).parents('#app-search-form').animate({width: '200px'})
...@@ -28,10 +28,3 @@ if window.location.pathname.match /^\/$/ ...@@ -28,10 +28,3 @@ if window.location.pathname.match /^\/$/
.done (data) -> .done (data) ->
$('#list_post').html(data) $('#list_post').html(data)
# search form animation
$('#app-search-form input')
.on 'focus', ->
$(this).parents('#app-search-form').animate({width: '600px'})
.on 'blur', ->
$(this).parents('#app-search-form').animate({width: '200px'})
.prettyprint {
/*.com { color: #93a1a1; }
.lit { color: #195f91; }
.pun, .opn, .clo { color: #93a1a1; }
.fun { color: #dc322f; }
.str, .atv { color: #D14; }
.kwd, .prettyprint .tag { color: #1e347b; }
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }*/
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
&.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
li {
margin: 0!important;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin: 0 0 0 33px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 20px;
text-shadow: 0 1px 0 #fff;
}
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8
{ list-style-type: decimal !important }
}
module ApplicationHelper module ApplicationHelper
class HTMLwithCoderay < Redcarpet::Render::HTML class HtmlWithPrettyPrint < Redcarpet::Render::HTML
def block_code(code, language) def postprocess(full_document)
case language.to_s full_document.gsub("prettyprint", "prettyprint linenums")
when 'rb'
lang = 'ruby'
when 'yml'
lang = 'yaml'
when ''
lang = 'md'
else
lang = 'md'
end
CodeRay.scan(code, lang).div
end end
end end
def h_application_format_markdown(text) def h_application_format_markdown(text)
html_render = HTMLwithCoderay.new(filter_html: true, hard_wrap: true) # html_render = HTMLwithCoderay.new(filter_html: true, hard_wrap: true, prettify: true)
html_render = HtmlWithPrettyPrint.new(:prettify => true)
options = { options = {
autolink: true, autolink: true,
space_after_headers: true, space_after_headers: true,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<%= javascript_include_tag "application" %> <%= javascript_include_tag "application" %>
<%= yield :footer_js %> <%= yield :footer_js %>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
</body> </body>
</html> </html>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form id="app-search-form" class="navbar-form navbar-left" role="search"> <form id="app-search-form" class="navbar-form navbar-left" role="search" action="/">
<div class="input-group"> <div class="input-group">
<input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="Search"> <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="Search">
<span class="input-group-btn"> <span class="input-group-btn">
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="row"> <div class="row">
<div class="col-xs-9 col-md-9" id="sidebar" role="navigation"> <div class="col-xs-12 col-md-12">
<div id="xxxxxxxx"> <div id="xxxxxxxx">
<%= render partial: 'posts/show_fragment' %> <%= render partial: 'posts/show_fragment' %>
...@@ -15,11 +15,6 @@ ...@@ -15,11 +15,6 @@
</div><!--/span--> </div><!--/span-->
<div class="col-xs-12 col-sm-3 col-md-9">
</div><!--/span-->
</div><!--/row--> </div><!--/row-->
<hr> <hr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment