Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Just simple content

  • Loading branch information...
commit 290917f587aa9ef7b798a0f8a63026303f47aa81 1 parent fe10537
@equivalent authored
View
1  Gemfile
@@ -1,7 +1,6 @@
source 'http://rubygems.org'
gem 'sinatra'
-gem "sinatra-content-for", :git => 'git@github.com:equivalent/sinatra-content-for.git'
gem 'haml'
gem 'sass'
View
14 Gemfile.lock
@@ -1,6 +1,15 @@
+GIT
+ remote: git@github.com:equivalent/sinatra-content-for.git
+ revision: 74e665e713726094b7f88e376e77a981784f9631
+ specs:
+ sinatra-content-for (0.2)
+ sinatra
+
GEM
remote: http://rubygems.org/
specs:
+ bourbon (1.4.0)
+ sass (>= 3.1)
coderay (1.0.5)
haml (3.1.4)
nokogiri (1.5.2)
@@ -13,18 +22,17 @@ GEM
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
- sinatra-content-for (0.2)
- sinatra
tilt (1.3.3)
PLATFORMS
ruby
DEPENDENCIES
+ bourbon
coderay
haml
nokogiri
redcarpet
sass
sinatra
- sinatra-content-for (~> 0.2)
+ sinatra-content-for!
View
5 helpers/helpers.rb
@@ -27,9 +27,10 @@ def coderay(text,lang='ruby')
def markdown(text)
- options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
+ options = {:hard_wrap => true, :filter_html => true, :autolink => true, :no_intraemphasis => true, :fenced_code => true, :gh_blockcode => true}
# options = [:filter_html, :hard_wrap, :autolink, :no_intraemphasis]
- syntax_highlighter(Redcarpet.new(text, *options).to_html)
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, options)
+ syntax_highlighter(markdown.render(text))
end
def syntax_highlighter(html)
View
61 lib/content_for.rb
@@ -0,0 +1,61 @@
+#
+##originaly from https://github.com/foca/sinatra-content-for but he remove support for this gem
+module Sinatra
+ module ContentFor
+ # Capture a block of content to be rendered later. For example:
+ #
+ # <% content_for :head do %>
+ # <script type="text/javascript" src="/foo.js"></script>
+ # <% end %>
+ #
+ # You can call +content_for+ multiple times with the same key
+ # (in the example +:head+), and when you render the blocks for
+ # that key all of them will be rendered, in the same order you
+ # captured them.
+ #
+ # Your blocks can also receive values, which are passed to them
+ # by <tt>yield_content</tt>
+ def content_for(key, &block)
+ content_blocks[key.to_sym] << block
+ end
+
+ # Render the captured blocks for a given key. For example:
+ #
+ # <head>
+ # <title>Example</title>
+ # <% yield_content :head %>
+ # </head>
+ #
+ # Would render everything you declared with <tt>content_for
+ # :head</tt> before closing the <tt><head></tt> tag.
+ #
+ # You can also pass values to the content blocks by passing them
+ # as arguments after the key:
+ #
+ # <% yield_content :head, 1, 2 %>
+ #
+ # Would pass <tt>1</tt> and <tt>2</tt> to all the blocks registered
+ # for <tt>:head</tt>.
+ #
+ # *NOTICE* that you call this without an <tt>=</tt> sign. IE,
+ # in a <tt><% %></tt> block, and not in a <tt><%= %></tt> block.
+ def yield_content(key, *args)
+ content_blocks[key.to_sym].map do |content|
+ if respond_to?(:block_is_haml?) && block_is_haml?(content)
+ capture_haml(*args, &content)
+ else
+ content.call(*args)
+ end
+ end.join
+ end
+
+ private
+
+ def content_blocks
+ @content_blocks ||= Hash.new {|h,k| h[k] = [] }
+ end
+ end
+
+ helpers ContentFor
+end
+
View
2  scrapbook.rb
@@ -1,6 +1,5 @@
require 'rubygems'
require 'sinatra'
-require 'sinatra/content_for'
require 'haml'
require 'redcarpet'
@@ -8,6 +7,7 @@
require 'nokogiri'
require 'sass/plugin/rack'
+require "#{File.dirname(__FILE__)}/lib/content_for.rb"
require "#{File.dirname(__FILE__)}/config_scrapbook.rb"
require "#{File.dirname(__FILE__)}/helpers/w_path.rb"
require "#{File.dirname(__FILE__)}/helpers/helpers.rb"
Please sign in to comment.
Something went wrong with that request. Please try again.