textile_manual 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ Feature: Path mounting
2
+ Scenario: Extension mounted at /manual
3
+ Given the textile Server is running at "manual_at_path"
4
+ When I go to "/manual"
5
+ Then I should see "is a simple text markup language"
6
+ When I click on the getting started link
7
+ Then I should be on /manual/writing-paragraph-text
8
+ When I click "Phrase modifiers" in the TOC
9
+ Then I should be on /manual/phrase-modifiers
10
+ When I click "Writing Paragraph Text" in the TOC
11
+ Then I should be on /manual/writing-paragraph-text
12
+ When I click "Introduction" in the TOC
13
+ Then I should be on /manual
14
+ And I should see "is a simple text markup language"
15
+
16
+ Scenario: Extension mounted at root
17
+ Given the textile Server is running at "manual_at_root"
18
+ When I go to "/"
19
+ Then I should see "is a simple text markup language"
20
+ When I click on the getting started link
21
+ Then I should be on /writing-paragraph-text
22
+ When I click "Phrase modifiers" in the TOC
23
+ Then I should be on /phrase-modifiers
24
+ When I click "Writing Paragraph Text" in the TOC
25
+ Then I should be on /writing-paragraph-text
26
+ When I click "Introduction" in the TOC
27
+ Then I should be on /
28
+ And I should see "is a simple text markup language"
@@ -0,0 +1,20 @@
1
+ When(/^I click on the getting started link$/) do
2
+ within(:css, ".content") do
3
+ click_link("Writing Paragraph Text")
4
+ end
5
+ end
6
+
7
+ When(/^I click "([^"]*)" in the TOC$/) do |text|
8
+ within(:css, ".table-of-contents") do
9
+ click_link text
10
+ end
11
+ end
12
+
13
+ Then /^(?:|I )should be on (.+)$/ do |page_path|
14
+ current_path = URI.parse(current_url).path
15
+ if current_path.respond_to? :should
16
+ current_path.should == page_path
17
+ else
18
+ assert_equal page_path, current_path
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'textile_manual')
@@ -0,0 +1,34 @@
1
+ Given /^the textile Server is running$/ do
2
+ root_dir = File.expand_path(expand_path("."))
3
+
4
+ ENV['MM_SOURCE'] = '../../../source'
5
+ ENV['MM_DATA_DIR'] = '../../../data'
6
+
7
+ ENV['MM_ROOT'] = root_dir
8
+
9
+ initialize_commands = @initialize_commands || []
10
+ activation_commands = @activation_commands || []
11
+
12
+ @server_inst = ::Middleman::Application.new do
13
+ config[:watcher_disable] = true
14
+ config[:show_exceptions] = false
15
+
16
+ initialize_commands.each do |p|
17
+ instance_exec(&p)
18
+ end
19
+
20
+ app.after_configuration_eval do
21
+ activation_commands.each do |p|
22
+ config_context.instance_exec(&p)
23
+ end
24
+ end
25
+ end
26
+
27
+ Capybara.app = ::Middleman::Rack.new(@server_inst).to_app
28
+ end
29
+
30
+ Given /^the textile Server is running at "([^\"]*)"$/ do |app_path|
31
+ step %Q{a fixture app "#{app_path}"}
32
+ step %Q{the textile Server is running}
33
+ end
34
+
@@ -0,0 +1,10 @@
1
+ config[:source] = '../../../source'
2
+ config[:data_dir] = '../../../data'
3
+
4
+ helpers do
5
+ def code(text)
6
+ text
7
+ end
8
+ end
9
+
10
+ activate :textile_manual, path: "/manual"
@@ -0,0 +1,10 @@
1
+ config[:source] = '../../../source'
2
+ config[:data_dir] = '../../../data'
3
+
4
+ helpers do
5
+ def code(text)
6
+ text
7
+ end
8
+ end
9
+
10
+ activate :textile_manual
@@ -0,0 +1,6 @@
1
+ require "middleman-core"
2
+
3
+ Middleman::Extensions.register :textile_manual do
4
+ require "textile_manual/extension"
5
+ TextileManual
6
+ end
@@ -0,0 +1,89 @@
1
+ # Require core library
2
+ require 'middleman-core'
3
+
4
+ # Extension namespace
5
+ class TextileManual < ::Middleman::Extension
6
+ option :path, '/', 'Path where you want to mount the textile reference manual'
7
+
8
+ def initialize(app, options_hash={}, &block)
9
+ # Call super to build options from the options_hash
10
+ super
11
+ add_extension_dirs
12
+
13
+ @sitemap = app.sitemap
14
+
15
+ @base_path = options.path
16
+ end
17
+
18
+ def textile_data
19
+ app.data.textile
20
+ end
21
+
22
+ # A Sitemap Manipulator
23
+ def manipulate_resource_list(resources)
24
+ new_resources = textile_data.map do |slug, contents|
25
+ build_proxy_resource(link(slug), contents)
26
+ end
27
+
28
+ new_resources << root_resource
29
+
30
+ new_resources.reduce(resources) do |sum, r|
31
+ r.execute_descriptor(app, sum)
32
+ end
33
+ end
34
+
35
+ def add_extension_dirs
36
+ app.files.watch :source, path: File.join(File.dirname(__FILE__), '../../source'), priority: 1
37
+ app.files.watch :data, path: File.join(File.dirname(__FILE__), '../../data'), priority: 1
38
+ end
39
+
40
+ helpers do
41
+ def textile_manual_link(path)
42
+ base = app.extensions[:textile_manual].options.path
43
+ File.join([base, path].compact)
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def link(slug=nil)
50
+ File.join([@base_path, slug, 'index.html'].compact)
51
+ end
52
+
53
+ def root_resource
54
+ build_proxy_resource(link, {}, 'textile_manual/index.html')
55
+ end
56
+
57
+ def build_proxy_resource(path, locals, template='textile_manual/chapter')
58
+ ProxyDescriptor.new(
59
+ ::Middleman::Util.normalize_path(path),
60
+ template,
61
+ { locals: locals,
62
+ ignore: true }
63
+ )
64
+ end
65
+
66
+ ProxyDescriptor = Struct.new(:path, :target, :metadata) do
67
+ def execute_descriptor(app, resources)
68
+ md = metadata.dup
69
+ should_ignore = md.delete(:ignore)
70
+
71
+ page_data = md.delete(:data) || {}
72
+ page_data[:id] = md.delete(:id) if md.key?(:id)
73
+
74
+ r = ::Middleman::Sitemap::ProxyResource.new(app.sitemap, path, target)
75
+ r.add_metadata(
76
+ locals: md.delete(:locals) || {},
77
+ page: page_data || {},
78
+ options: md
79
+ )
80
+
81
+ if should_ignore
82
+ d = ::Middleman::Sitemap::Extensions::Ignores::StringIgnoreDescriptor.new(target)
83
+ d.execute_descriptor(app, resources)
84
+ end
85
+
86
+ resources + [r]
87
+ end
88
+ end
89
+ end
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ //= require jquery/dist/jquery
2
+ //= require what-input/what-input.min
3
+ //= require foundation-sites/dist/foundation.min
4
+
5
+ //= require app
File without changes
@@ -0,0 +1 @@
1
+ //= require modernizr/modernizr
@@ -0,0 +1,23 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"
5
+ meta charset="utf-8"
6
+ meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"
7
+
8
+ title = strip_tags(current_page.data.title || title)
9
+
10
+ == stylesheet_link_tag :style
11
+ == javascript_include_tag "modernizr"
12
+
13
+ body class="#{page_classes}"
14
+ article.textile-manual
15
+ .row
16
+ .small-12.medium-9.columns
17
+ header.page-header
18
+ h1= current_page.data.title || title
19
+ .content
20
+ == yield
21
+ .hide-for-small-only.medium-3.columns
22
+ = partial 'partials/textile_toc', locals: {contents: data.textile}
23
+ = javascript_include_tag "all"
@@ -0,0 +1,12 @@
1
+ .table-of-contents
2
+ - if current_page.data.title.blank?
3
+ .strong-text Textile Reference Manual
4
+ ul.no-bullet
5
+ li= link_to 'Introduction', textile_manual_link(nil)
6
+ - contents.each do |slug, chapter|
7
+ li
8
+ = link_to chapter.title, textile_manual_link(slug)
9
+ ul
10
+ - chapter.sections.each do |anchor, section|
11
+ li= link_to section.keys.first, textile_manual_link("#{slug}##{anchor}")
12
+
@@ -0,0 +1,209 @@
1
+ .highlight table td { padding: 5px; }
2
+ .highlight table pre { margin: 0; }
3
+ .highlight .cm {
4
+ color: #999988;
5
+ font-style: italic;
6
+ }
7
+ .highlight .cp {
8
+ color: #999999;
9
+ font-weight: bold;
10
+ }
11
+ .highlight .c1 {
12
+ color: #999988;
13
+ font-style: italic;
14
+ }
15
+ .highlight .cs {
16
+ color: #999999;
17
+ font-weight: bold;
18
+ font-style: italic;
19
+ }
20
+ .highlight .c, .highlight .cd {
21
+ color: #999988;
22
+ font-style: italic;
23
+ }
24
+ .highlight .err {
25
+ color: #a61717;
26
+ background-color: #e3d2d2;
27
+ }
28
+ .highlight .gd {
29
+ color: #000000;
30
+ background-color: #ffdddd;
31
+ }
32
+ .highlight .ge {
33
+ color: #000000;
34
+ font-style: italic;
35
+ }
36
+ .highlight .gr {
37
+ color: #aa0000;
38
+ }
39
+ .highlight .gh {
40
+ color: #999999;
41
+ }
42
+ .highlight .gi {
43
+ color: #000000;
44
+ background-color: #ddffdd;
45
+ }
46
+ .highlight .go {
47
+ color: #888888;
48
+ }
49
+ .highlight .gp {
50
+ color: #555555;
51
+ }
52
+ .highlight .gs {
53
+ font-weight: bold;
54
+ }
55
+ .highlight .gu {
56
+ color: #aaaaaa;
57
+ }
58
+ .highlight .gt {
59
+ color: #aa0000;
60
+ }
61
+ .highlight .kc {
62
+ color: #000000;
63
+ font-weight: bold;
64
+ }
65
+ .highlight .kd {
66
+ color: #000000;
67
+ font-weight: bold;
68
+ }
69
+ .highlight .kn {
70
+ color: #000000;
71
+ font-weight: bold;
72
+ }
73
+ .highlight .kp {
74
+ color: #000000;
75
+ font-weight: bold;
76
+ }
77
+ .highlight .kr {
78
+ color: #000000;
79
+ font-weight: bold;
80
+ }
81
+ .highlight .kt {
82
+ color: #445588;
83
+ font-weight: bold;
84
+ }
85
+ .highlight .k, .highlight .kv {
86
+ color: #000000;
87
+ font-weight: bold;
88
+ }
89
+ .highlight .mf {
90
+ color: #009999;
91
+ }
92
+ .highlight .mh {
93
+ color: #009999;
94
+ }
95
+ .highlight .il {
96
+ color: #009999;
97
+ }
98
+ .highlight .mi {
99
+ color: #009999;
100
+ }
101
+ .highlight .mo {
102
+ color: #009999;
103
+ }
104
+ .highlight .m, .highlight .mb, .highlight .mx {
105
+ color: #009999;
106
+ }
107
+ .highlight .sb {
108
+ color: #d14;
109
+ }
110
+ .highlight .sc {
111
+ color: #d14;
112
+ }
113
+ .highlight .sd {
114
+ color: #d14;
115
+ }
116
+ .highlight .s2 {
117
+ color: #d14;
118
+ }
119
+ .highlight .se {
120
+ color: #d14;
121
+ }
122
+ .highlight .sh {
123
+ color: #d14;
124
+ }
125
+ .highlight .si {
126
+ color: #d14;
127
+ }
128
+ .highlight .sx {
129
+ color: #d14;
130
+ }
131
+ .highlight .sr {
132
+ color: #009926;
133
+ }
134
+ .highlight .s1 {
135
+ color: #d14;
136
+ }
137
+ .highlight .ss {
138
+ color: #990073;
139
+ }
140
+ .highlight .s {
141
+ color: #d14;
142
+ }
143
+ .highlight .na {
144
+ color: #008080;
145
+ }
146
+ .highlight .bp {
147
+ color: #999999;
148
+ }
149
+ .highlight .nb {
150
+ color: #0086B3;
151
+ }
152
+ .highlight .nc {
153
+ color: #445588;
154
+ font-weight: bold;
155
+ }
156
+ .highlight .no {
157
+ color: #008080;
158
+ }
159
+ .highlight .nd {
160
+ color: #3c5d5d;
161
+ font-weight: bold;
162
+ }
163
+ .highlight .ni {
164
+ color: #800080;
165
+ }
166
+ .highlight .ne {
167
+ color: #990000;
168
+ font-weight: bold;
169
+ }
170
+ .highlight .nf {
171
+ color: #990000;
172
+ font-weight: bold;
173
+ }
174
+ .highlight .nl {
175
+ color: #990000;
176
+ font-weight: bold;
177
+ }
178
+ .highlight .nn {
179
+ color: #555555;
180
+ }
181
+ .highlight .nt {
182
+ color: #000080;
183
+ }
184
+ .highlight .vc {
185
+ color: #008080;
186
+ }
187
+ .highlight .vg {
188
+ color: #008080;
189
+ }
190
+ .highlight .vi {
191
+ color: #008080;
192
+ }
193
+ .highlight .nv {
194
+ color: #008080;
195
+ }
196
+ .highlight .ow {
197
+ color: #000000;
198
+ font-weight: bold;
199
+ }
200
+ .highlight .o {
201
+ color: #000000;
202
+ font-weight: bold;
203
+ }
204
+ .highlight .w {
205
+ color: #bbbbbb;
206
+ }
207
+ .highlight {
208
+ background-color: #f8f8f8;
209
+ }