rack-footnotes 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +22 -0
- data/lib/rack/footnotes.rb +31 -0
- data/rack-footnotes.gemspec +28 -0
- metadata +82 -0
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Rack FootNotes
|
2
|
+
|
3
|
+
Rack::FootNotes is a very simple middleware I coded to add footnotes to prototypes created with [jlong/serve](http://github.com/jlong/serve)
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Create a `notes` folder in your serve project's root. Add a text file with notes for every route you want to display notes in. I.e: if you want to show notes for `http://0.0.0.0:4000/foo/bar/`, add them to `notes/foo/bar.txt`
|
8
|
+
|
9
|
+
Then, load Rack::FootNotes in your `config.ru`:
|
10
|
+
|
11
|
+
gem 'rack-footnotes'
|
12
|
+
require 'rack/footnotes'
|
13
|
+
use Rack::FootNotes, {
|
14
|
+
:notes_path => 'notes',
|
15
|
+
:extra_css => "text-align: center;"
|
16
|
+
}
|
17
|
+
|
18
|
+
There are three options:
|
19
|
+
|
20
|
+
* `:notes_path`, the folder where you want to store your notes
|
21
|
+
* `:css`, the CSS for the div containing the notes (don't change this unless necessary)
|
22
|
+
* `:extra_css`, styles that will be added to the default CSS. Use it to change the background color, font-face, etc...
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "rack"
|
2
|
+
|
3
|
+
class Rack::FootNotes
|
4
|
+
|
5
|
+
VERSION = "0.0.1"
|
6
|
+
|
7
|
+
def initialize(app, options = {}, &block)
|
8
|
+
@app = app
|
9
|
+
@options = {
|
10
|
+
:notes_path => 'notes',
|
11
|
+
:css => "position: fixed; bottom: 0; left: 0; width: 100%; padding: 1em; background-color: rgba(245,242,137,0.6); margin: 0 auto;",
|
12
|
+
:extra_css => ""
|
13
|
+
}.merge(options)
|
14
|
+
instance_eval(&block) if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
status, headers, body = @app.call(env)
|
19
|
+
|
20
|
+
route = env['PATH_INFO']
|
21
|
+
file = Dir.pwd + "/#{@options[:notes_path]}" + route.gsub(/\/$/,'') + '.txt'
|
22
|
+
if File.exists?(file)
|
23
|
+
note = File.readlines(file).to_s
|
24
|
+
body.body.gsub!("</body>","<div id='racknotes'>#{note}</div><style>#racknotes { #{@options[:css]} #{@options[:extra_css]} }</style></body>")
|
25
|
+
end
|
26
|
+
|
27
|
+
@response = Rack::Response.new(body, status, headers)
|
28
|
+
@response.to_a
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{rack-footnotes}
|
3
|
+
s.version = "0.0.1"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["Ale Muñoz"]
|
7
|
+
s.date = %q{2010-12-23}
|
8
|
+
s.description = %q{Rack middleware to insert text comments into pages. First created to be used with jlong's serve, but should work with pretty much every rack app}
|
9
|
+
s.files = ["lib/rack/footnotes.rb", "rack-footnotes.gemspec", "README.md"]
|
10
|
+
s.homepage = %q{http://github.com/bomberstudios/rack-footnotes}
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.has_rdoc = false
|
13
|
+
s.rubygems_version = %q{1.3.6}
|
14
|
+
s.summary = %q{Rack middleware to insert text comments into pages}
|
15
|
+
|
16
|
+
if s.respond_to? :specification_version then
|
17
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
18
|
+
s.specification_version = 3
|
19
|
+
|
20
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
21
|
+
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
22
|
+
else
|
23
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
24
|
+
end
|
25
|
+
else
|
26
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-footnotes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Ale Mu\xC3\xB1oz"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-23 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rack
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Rack middleware to insert text comments into pages. First created to be used with jlong's serve, but should work with pretty much every rack app
|
36
|
+
email:
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/rack/footnotes.rb
|
45
|
+
- rack-footnotes.gemspec
|
46
|
+
- README.md
|
47
|
+
has_rdoc: false
|
48
|
+
homepage: http://github.com/bomberstudios/rack-footnotes
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.3.7
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Rack middleware to insert text comments into pages
|
81
|
+
test_files: []
|
82
|
+
|