Permalink
Browse files

merge from elite28's fork

  • Loading branch information...
1 parent ae858e0 commit 403b49ae870cdadb51e5356e84758413488a17fb @ZhangHanDong committed Jun 30, 2011
View
@@ -11,6 +11,10 @@ Rails3.0.8+/Ruby1.8.7+
## Usage:
+**you need install pygments**
+
+ easy_install pygments
+
a. In Gemfile:
gem "redcarpet"
@@ -27,6 +31,10 @@ c. In layout:
= stylesheet_link_tag :markitup
= javascript_include_tag :markitup
+ or you can use another highlight css:
+
+ = stylesheet_link_tag :markitup_shiny
+
d. In your textarea , simple\_form\_for exapmle:
= form.input :content, :as => :text, :input_html => {:id => 'markdown'}
@@ -41,3 +49,7 @@ f. In your show page:
= markdown(@topic.content)
+ if you use shiny style
+
+ = markdown(@topic.content, 'shiny')
+
@@ -1,8 +1,10 @@
module MarkitupHelper
- def markdown(text)
- options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
- syntax_highlighter(Redcarpet.new(text, *options).to_html).html_safe
- end
+
+ def markdown(text, style="bright")
+ options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
+ content_tag(:div, :class => "#{style}"){syntax_highlighter(Redcarpet.new(text, *options).to_html).html_safe}
+ end
+
def syntax_highlighter(html)
doc = Nokogiri::HTML(html)
@@ -18,10 +18,13 @@ def copy_media_files
@images.each do |image|
copy_file "#{image}", "public/stylesheets/markitup/image/#{image.split('/').last}"
end
- copy_file "../media/javascripts/jquery.markitup.js", "public/javascripts/markitup/jquery.markitup.js"
- copy_file "../media/javascripts/sets/markdown/set.js", "public/javascripts/markitup/sets/markdown/set.js"
- copy_file "../media/stylesheets/sets/markdown/style.css", "public/stylesheets/markitup/sets/markdown/style.css"
- copy_file "../media/stylesheets/skins/markitup/style.css", "public/stylesheets/markitup/skins/markdown/style.css"
+ copy_file "../media/javascripts/jquery.markitup.js", "public/javascripts/markitup/jquery.markitup.js"
+ copy_file "../media/javascripts/sets/markdown/set.js", "public/javascripts/markitup/sets/markdown/set.js"
+ copy_file "../media/stylesheets/sets/markdown/style.css", "public/stylesheets/markitup/sets/markdown/style.css"
+ copy_file "../media/stylesheets/skins/markitup/style.css", "public/stylesheets/markitup/skins/markdown/style.css"
+ copy_file "../media/stylesheets/skins/markitup/bright.css", "public/stylesheets/markitup/skins/markdown/bright.css"
+ copy_file "../media/stylesheets/skins/markitup/pygments.css", "public/stylesheets/markitup/skins/markdown/pygments.css"
+ copy_file "../media/stylesheets/skins/markitup/shiny.css", "public/stylesheets/markitup/skins/markdown/shiny.css"
end
end
@@ -0,0 +1,69 @@
+/* ================================= */
+/* = Common Stuff for all Commands = */
+/* ================================= */
+
+.bright {
+ background: #FFF;
+ color: #000;
+}
+.bright a {
+ color: #0D2681;
+}
+
+.bright h1 {
+ text-shadow: #DDDDDD 3px 3px 5px;
+ color: #333;
+}
+.bright h2 {
+ color: #222;
+ text-shadow: #DDDDDD 3px 3px 5px;
+}
+.bright h3 {
+ color: #333;
+ text-shadow: #DDDDDD 3px 3px 5px;
+}
+.bright h4 {
+ color: #666;
+}
+
+.bright blockquote {
+ border-left: 4px solid #E6E5DD;
+}
+.bright code {
+ color: #1C360C;
+}
+
+.bright pre {
+ background-color: #f0f0f0;
+ border: 1px solid #cccbba;
+}
+
+.bright .pro_table {
+ border-top: 1px solid #919699;
+ border-left: 1px solid #919699;
+}
+.bright .pro_table th {
+ background: #E2E2E2;
+ border-bottom: 1px solid #919699;
+ border-right: 1px solid #919699;
+}
+.bright .pro_table td {
+ border-bottom: 1px solid #919699;
+ border-right: 1px solid #919699;
+}
+.bright .footnote {
+ color: #525151;
+}
+.bright .footnote:before {
+ color: #525151;
+}
+.bright .footnote:after {
+ color: #525151;
+}
+.bright div.footnotes {
+ background: #F0F0F0;
+}
+
+.bright .alternate {
+ background-color: #F0F0F0;
+}
@@ -0,0 +1,61 @@
+.hll { background-color: #ffffcc }
+.c { color: #408080; font-style: italic } /* Comment */
+.err { border: 1px solid #FF0000 } /* Error */
+.k { color: #008000; font-weight: bold } /* Keyword */
+.o { color: #666666 } /* Operator */
+.cm { color: #408080; font-style: italic } /* Comment.Multiline */
+.cp { color: #BC7A00 } /* Comment.Preproc */
+.c1 { color: #408080; font-style: italic } /* Comment.Single */
+.cs { color: #408080; font-style: italic } /* Comment.Special */
+.gd { color: #A00000 } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #FF0000 } /* Generic.Error */
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.gi { color: #00A000 } /* Generic.Inserted */
+.go { color: #808080 } /* Generic.Output */
+.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.gt { color: #0040D0 } /* Generic.Traceback */
+.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.kp { color: #008000 } /* Keyword.Pseudo */
+.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #B00040 } /* Keyword.Type */
+.m { color: #666666 } /* Literal.Number */
+.s { color: #BA2121 } /* Literal.String */
+.na { color: #7D9029 } /* Name.Attribute */
+.nb { color: #008000 } /* Name.Builtin */
+.nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.no { color: #880000 } /* Name.Constant */
+.nd { color: #AA22FF } /* Name.Decorator */
+.ni { color: #999999; font-weight: bold } /* Name.Entity */
+.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.nf { color: #0000FF } /* Name.Function */
+.nl { color: #A0A000 } /* Name.Label */
+.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.nt { color: #008000; font-weight: bold } /* Name.Tag */
+.nv { color: #19177C } /* Name.Variable */
+.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.w { color: #bbbbbb } /* Text.Whitespace */
+.mf { color: #666666 } /* Literal.Number.Float */
+.mh { color: #666666 } /* Literal.Number.Hex */
+.mi { color: #666666 } /* Literal.Number.Integer */
+.mo { color: #666666 } /* Literal.Number.Oct */
+.sb { color: #BA2121 } /* Literal.String.Backtick */
+.sc { color: #BA2121 } /* Literal.String.Char */
+.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.s2 { color: #BA2121 } /* Literal.String.Double */
+.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.sh { color: #BA2121 } /* Literal.String.Heredoc */
+.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.sx { color: #008000 } /* Literal.String.Other */
+.sr { color: #BB6688 } /* Literal.String.Regex */
+.s1 { color: #BA2121 } /* Literal.String.Single */
+.ss { color: #19177C } /* Literal.String.Symbol */
+.bp { color: #008000 } /* Name.Builtin.Pseudo */
+.vc { color: #19177C } /* Name.Variable.Class */
+.vg { color: #19177C } /* Name.Variable.Global */
+.vi { color: #19177C } /* Name.Variable.Instance */
+.il { color: #666666 } /* Literal.Number.Integer.Long */
@@ -0,0 +1,76 @@
+/* =================== */
+/* = General Styling = */
+/* =================== */
+.shiny {
+ background: #000;
+ color: #E6E2E8;
+}
+.shiny a {
+ color: #BBE;
+}
+
+.shiny h1 {
+ color: #FFF;
+ text-shadow: #808080 3px 3px 5px;
+}
+
+.shiny h2 {
+ text-shadow: #808080 3px 3px 5px;
+}
+
+.shiny h3 {
+ text-shadow: #808080 3px 3px 5px;
+}
+
+.shiny blockquote {
+ border-left: 4px solid #808080;
+ color: #FFF;
+}
+
+.shiny code {
+ color: #C1DE77;
+}
+
+.shiny pre {
+ color: #FFF;
+ background-color: #111;
+ border: 1px solid #555;
+}
+
+
+.shiny .pro_table {
+ border-top: 1px solid #616465;
+ border-left: 1px solid #616465;
+}
+.shiny .pro_table th {
+ background: #1C1C1C;
+ border-bottom: 1px solid #616465;
+ border-right: 1px solid #616465;
+}
+.shiny .pro_table td {
+ border-bottom: 1px solid #616465;
+ border-right: 1px solid #616465;
+}
+.shiny .footnote:before {
+ color: #888;
+}
+.shiny .footnote:after {
+ color: #888;
+}
+
+.shiny div.footnotes {
+ background: #111;
+}
+
+
+.shiny td, .dark th {
+ color: #EEE;
+}
+
+.shiny caption, .dark label {
+ color: #CCC;
+}
+
+.shiny .alternate {
+ background-color: #111;
+}
@@ -14,7 +14,8 @@ class Engine < Rails::Engine
# =====================================
config.before_initialize do
config.action_view.javascript_expansions[:markitup] = %w(markitup/jquery.markitup.js markitup/sets/markdown/set.js)
- config.action_view.stylesheet_expansions[:markitup] = %w(markitup/sets/markdown/style.css markitup/skins/markdown/style.css)
+ config.action_view.stylesheet_expansions[:markitup] = %w(markitup/sets/markdown/style.css markitup/skins/markdown/style.css markitup/skins/markdown/bright.css markitup/skins/markdown/pygments.css)
+ config.action_view.stylesheet_expansions[:markitup_shiny] = %w(markitup/sets/markdown/style.css markitup/skins/markdown/style.css markitup/skins/markdown/shiny.css markitup/skins/markdown/pygments.css)
end
end
View
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
- s.add_dependency "rails", "3.0.8"
+ s.add_dependency "rails", ">= 3.0.8"
s.add_dependency "redcarpet"
s.add_dependency "albino"
s.add_dependency "nokogiri"

0 comments on commit 403b49a

Please sign in to comment.