anatomy 0.2.7 → 0.2.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd164380607baf3afe9c067472e0031083fed64
4
- data.tar.gz: 6d495bd0291c600e20615e2b07cfa91bc7e86da5
3
+ metadata.gz: f7fe0292092b1f5f8c4b8faf016842ba82284e0d
4
+ data.tar.gz: 67f1f1bda845a392804d273699d8b3dbe452f574
5
5
  SHA512:
6
- metadata.gz: 968bba17c98053fc513f12ea285f654a1c5b0a6df10249986943e39b64936f9373bde69e10bd0db77e7a5c8b5ac59b59cf3752d42457a1260edee114bded5dbc
7
- data.tar.gz: 49998d10fe5426aa5954d905159065ab45c04368648497d820b1b54892ab465b9b4b5747d3e8fda1d97403fffce637b2e4a563babc15260146ca2f78340a8a21
6
+ metadata.gz: 72d6808da8d14a041d969b1b3f351372a757c09e4e2c55bf40e548020805c12020b5752f8509ee8e1b8fa4dcb0256535596c428200a0a5310672efb63da68c59
7
+ data.tar.gz: fc57e898e578ebfcc39f1b5eee4d49e50b67d4512d9ba78c026ef0b466497edbf2deff1b28f60c7338c5dee8251e63ea74d4e9f2460b35b462acdd60663ff625
@@ -67,6 +67,9 @@ data(
67
67
  @css-additions = Set new
68
68
  @css-url-additions = Set new
69
69
 
70
+ -- js files to add (array since order matters)
71
+ @js-additions = []
72
+
70
73
  -- template to use when rendering html
71
74
  @template = nil
72
75
 
@@ -99,6 +102,9 @@ def(Part section-label):
99
102
 
100
103
  def(Part inspect): i"#<Part: '#{@tag name}'>"
101
104
 
105
+ def(Part template):
106
+ @template || (@parent && @parent template)
107
+
102
108
  -- search in order:
103
109
  -- 1. local hidden tags
104
110
  -- 2. local tags
@@ -30,11 +30,4 @@ def(process(input, renderer, output = ".")):
30
30
  unless(Dir exists?(output)):
31
31
  Dir mkdir(output)
32
32
 
33
- unless(Dir exists?(output + "/public")):
34
- Dir mkdir(output + "/public")
35
-
36
- FileUtils cp-r(
37
- File expand-path("../../../public", __FILE__) + "/."
38
- output + "/public")
39
-
40
33
  renderer render(part, output)
@@ -241,14 +241,16 @@ def(toc-leaf(current-part, part)):
241
241
 
242
242
 
243
243
  def(render(part, out = ".")):
244
+ tags-file = i"#{Dir tmpdir}/#{part top tag name}-tags.js"
245
+
244
246
  unless(part parent):
245
247
  tags = search-tags(part) collect [t, d, u]:
246
248
  [t, d to-s, u]
247
249
 
248
- File open(i"#{out}/public/tags.js", "w") [f]:
250
+ File open(tags-file, "w") [f]:
249
251
  f write(i"var SEARCH_TAGS = #{tags to-json};")
250
252
 
251
- copy-all-assets(part, out)
253
+ part js-additions << tags-file
252
254
 
253
255
  -- call this early so the template can register its own assets/etc
254
256
  template = render-part-template(part, out)
@@ -266,19 +268,12 @@ def(render(part, out = ".")):
266
268
  <meta("http-equiv" = "Content-Type", content = "text/html; charset=UTF-8")
267
269
  <title: StrippedTags new(over(part title))
268
270
 
269
- unless(part template):
270
- [ <link(type = "text/css", rel = "stylesheet", href = "public/anatomy.css")
271
- <link(type = "text/css", rel = "stylesheet", href = "public/highlight.css")
272
- ]
273
-
274
- <script(type = "text/javascript", src = "public/jquery.js") {}
275
- <script(type = "text/javascript", src = "public/jquery.hotkeys.js") {}
276
- <script(type = "text/javascript", src = "public/tags.js") {}
277
- <script(type = "text/javascript", src = "public/main.js") {}
278
-
279
271
  when(part mobile-optimized?):
280
272
  <meta(name = "viewport", content = "width=device-width, initial-scale=1")
281
273
 
274
+ all-js-additions(part) collect [addition]:
275
+ <script(type = "text/javascript", src = addition) {}
276
+
282
277
  all-css-additions(part) collect [addition]:
283
278
  <link(type = "text/css", rel = "stylesheet", href = addition)
284
279
 
@@ -310,6 +305,8 @@ def(all-part-assets(part)):
310
305
 
311
306
  assets += part css-additions to-a
312
307
 
308
+ assets += part js-additions to-a
309
+
313
310
  part parts collect [sub]:
314
311
  assets += all-part-assets(sub)
315
312
 
@@ -319,7 +316,17 @@ def(copy-all-assets(part, out)):
319
316
  all-part-assets(part) each [a]:
320
317
  sync-asset-to(a, out)
321
318
 
319
+ def(search-js-additions):
320
+ [ File expand-path("../js/jquery.js", __FILE__)
321
+ File expand-path("../js/search.js", __FILE__)
322
+ ]
323
+
322
324
  def(template-for(part, out)):
325
+ part css-additions << File expand-path("../css/anatomy.css", __FILE__)
326
+ part css-additions << File expand-path("../css/highlight.css", __FILE__)
327
+
328
+ part js-additions += search-js-additions
329
+
323
330
  <div(#page):
324
331
  <div(#main):
325
332
  <div(#content):
@@ -436,3 +443,16 @@ def(all-css-additions(p)):
436
443
  all-assets += all-css-additions(sub)
437
444
 
438
445
  all-assets
446
+
447
+ def(all-js-additions(p)):
448
+ all-assets = []
449
+
450
+ p js-additions each [file]:
451
+ all-assets << File basename(file)
452
+
453
+ p parts each [sub]:
454
+ -- exclude parts that have their own page
455
+ unless(top(sub) == sub):
456
+ all-assets += all-js-additions(sub)
457
+
458
+ all-assets
@@ -0,0 +1,39 @@
1
+ function bindSearch() {
2
+ $("#search").keyup(function() {
3
+ $(".search-results").empty();
4
+
5
+ if (!$("#search").val().length) {
6
+ $(".search-results").hide();
7
+ return;
8
+ }
9
+
10
+ var q = $("#search").val().toLowerCase(),
11
+ matches = [];
12
+
13
+ $.each(SEARCH_TAGS, function(i, t){
14
+ var k = t[0].toLowerCase(),
15
+ n = t[1],
16
+ url = t[2],
17
+ item = "<li>" + n + "</li>";
18
+
19
+ if (k.indexOf(q) == -1 || matches.indexOf(url) != -1)
20
+ return;
21
+
22
+ matches.push(url);
23
+
24
+ if (k == q)
25
+ $(".search-results").prepend(item);
26
+ else
27
+ $(".search-results").append(item);
28
+ });
29
+
30
+ if (matches.length == 0)
31
+ $(".search-results").hide();
32
+ else
33
+ $(".search-results").show();
34
+ });
35
+ }
36
+
37
+ $(function() {
38
+ bindSearch();
39
+ });
@@ -8,11 +8,6 @@ var X_OFFSET = 50,
8
8
  SLIDE_HEIGHT;
9
9
 
10
10
  $(function(){
11
- bindSearch();
12
-
13
- if (!$(".slides").length)
14
- return;
15
-
16
11
  SLIDE_WIDTH = $(".slide").outerWidth();
17
12
  SLIDE_HEIGHT = $(".slide").outerHeight();
18
13
 
@@ -106,43 +101,6 @@ function bindTouch() {
106
101
  });
107
102
  }
108
103
 
109
- function bindSearch() {
110
- $("#search").keyup(function(){
111
- $(".search-results").empty();
112
-
113
- if (!$("#search").val().length) {
114
- $(".search-results").hide();
115
- return;
116
- }
117
-
118
- var q = $("#search").val().toLowerCase(),
119
- matches = [];
120
-
121
- console.log(q, SEARCH_TAGS);
122
- $.each(SEARCH_TAGS, function(i, t){
123
- var k = t[0].toLowerCase(),
124
- n = t[1],
125
- url = t[2],
126
- item = "<li>" + n + "</li>";
127
-
128
- if (k.indexOf(q) == -1 || matches.indexOf(url) != -1)
129
- return;
130
-
131
- matches.push(url);
132
-
133
- if (k == q)
134
- $(".search-results").prepend(item);
135
- else
136
- $(".search-results").append(item);
137
- });
138
-
139
- if (matches.length == 0)
140
- $(".search-results").hide();
141
- else
142
- $(".search-results").show();
143
- });
144
- }
145
-
146
104
  function moveX(diff) {
147
105
  animating = true;
148
106
  position -= diff;
@@ -6,6 +6,9 @@ data = require("anatomy/data")
6
6
  def(slides):
7
7
  data MetaBlock new(
8
8
  [part]:
9
+ part js-additions << File expand-path("../slides-js/jquery.hotkeys.js")
10
+ part js-additions << File expand-path("../slides-js/slides.js")
11
+
9
12
  part style properties << .slides)
10
13
 
11
14
 
@@ -53,10 +53,6 @@ def(pass(a & Array, part, body = part body)):
53
53
  def(pass(p & data Part, part, body = part body)):
54
54
  part parts << p
55
55
  p parent = part
56
-
57
- unless(p template):
58
- p template = part template
59
-
60
56
  part body freeze
61
57
  nil
62
58
 
@@ -1,3 +1,3 @@
1
1
  module Anatomy
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anatomy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Suraci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: atomy
15
- type: :runtime
16
14
  requirement: !ruby/object:Gem::Requirement
17
15
  requirements:
18
16
  - - "~>"
19
17
  - !ruby/object:Gem::Version
20
18
  version: 0.6.3
19
+ name: atomy
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: 0.6.3
27
- - !ruby/object:Gem::Dependency
28
- name: broomhlda
29
26
  type: :runtime
27
+ - !ruby/object:Gem::Dependency
30
28
  requirement: !ruby/object:Gem::Requirement
31
29
  requirements:
32
30
  - - "~>"
33
31
  - !ruby/object:Gem::Version
34
32
  version: 0.2.0
33
+ name: broomhlda
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: 0.2.0
41
- - !ruby/object:Gem::Dependency
42
- name: json_pure
43
40
  type: :runtime
41
+ - !ruby/object:Gem::Dependency
44
42
  requirement: !ruby/object:Gem::Requirement
45
43
  requirements:
46
44
  - - "~>"
47
45
  - !ruby/object:Gem::Version
48
46
  version: '1.8'
47
+ name: json_pure
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '1.8'
54
+ type: :runtime
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
57
- type: :development
58
56
  requirement: !ruby/object:Gem::Requirement
59
57
  requirements:
60
58
  - - "~>"
61
59
  - !ruby/object:Gem::Version
62
60
  version: '10.4'
61
+ name: rake
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
67
  version: '10.4'
68
+ type: :development
69
69
  description: "\n A document authoring system inspired by Scribble.\n "
70
70
  email:
71
71
  - suraci.alex@gmail.com
@@ -84,20 +84,21 @@ files:
84
84
  - lib/anatomy/html.ay
85
85
  - lib/anatomy/language/parser.ay
86
86
  - lib/anatomy/processor.ay
87
+ - lib/anatomy/renderers/css/anatomy.css
88
+ - lib/anatomy/renderers/css/highlight.css
87
89
  - lib/anatomy/renderers/html.ay
90
+ - lib/anatomy/renderers/js/jquery.js
91
+ - lib/anatomy/renderers/js/search.js
88
92
  - lib/anatomy/ruby.ay
89
93
  - lib/anatomy/server.ay
94
+ - lib/anatomy/slides-js/jquery.hotkeys.js
95
+ - lib/anatomy/slides-js/slides.js
90
96
  - lib/anatomy/slides.ay
91
97
  - lib/anatomy/stages/collect.ay
92
98
  - lib/anatomy/stages/meta.ay
93
99
  - lib/anatomy/stages/resolve.ay
94
100
  - lib/anatomy/stages/traverse.ay
95
101
  - lib/anatomy/version.rb
96
- - public/anatomy.css
97
- - public/highlight.css
98
- - public/jquery.hotkeys.js
99
- - public/jquery.js
100
- - public/main.js
101
102
  homepage: https://vito.github.io/atomy
102
103
  licenses:
103
104
  - Apache-2.0