spirit 0.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/lib/spirit.rb +8 -10
  3. data/lib/spirit/constants.rb +17 -7
  4. data/lib/spirit/document.rb +4 -9
  5. data/lib/spirit/errors.rb +0 -1
  6. data/lib/spirit/logger.rb +5 -6
  7. data/lib/spirit/manifest.rb +4 -5
  8. data/lib/spirit/render.rb +0 -2
  9. data/lib/spirit/render/errors.rb +0 -4
  10. data/lib/spirit/render/html.rb +17 -117
  11. data/lib/spirit/render/processable.rb +78 -0
  12. data/lib/spirit/render/processors.rb +15 -0
  13. data/lib/spirit/render/processors/base.rb +40 -0
  14. data/lib/spirit/render/processors/block_image_processor.rb +49 -0
  15. data/lib/spirit/render/processors/headers_processor.rb +41 -0
  16. data/lib/spirit/render/processors/layout_processor.rb +28 -0
  17. data/lib/spirit/render/processors/math_processor.rb +102 -0
  18. data/lib/spirit/render/processors/problems_processor.rb +76 -0
  19. data/lib/spirit/render/processors/pygments_processor.rb +22 -0
  20. data/lib/spirit/render/processors/sanitize_processor.rb +86 -0
  21. data/lib/spirit/render/templates.rb +1 -3
  22. data/lib/spirit/render/templates/header.rb +2 -3
  23. data/lib/spirit/render/templates/image.rb +6 -13
  24. data/lib/spirit/render/templates/multi.rb +9 -10
  25. data/lib/spirit/render/templates/navigation.rb +4 -5
  26. data/lib/spirit/render/templates/problem.rb +24 -28
  27. data/lib/spirit/render/templates/short.rb +2 -3
  28. data/lib/spirit/render/templates/table.rb +2 -2
  29. data/lib/spirit/render/templates/template.rb +12 -8
  30. data/lib/spirit/version.rb +1 -2
  31. data/views/header.haml +1 -1
  32. data/views/img.haml +2 -2
  33. data/views/layout.haml +27 -0
  34. data/views/multi.haml +10 -14
  35. data/views/nav.haml +2 -2
  36. data/views/short.haml +6 -11
  37. data/views/table.haml +20 -26
  38. metadata +36 -57
  39. data/lib/spirit/render/sanitize.rb +0 -90
  40. data/views/exe.haml +0 -5
@@ -1,90 +0,0 @@
1
- # ~*~ encoding: utf-8 ~*~
2
- require 'sanitize'
3
-
4
- module Spirit
5
-
6
- module Render
7
-
8
- # Encapsulate sanitization options.
9
- # @see https://github.com/github/gollum/blob/master/lib/gollum/sanitization.rb
10
- class Sanitize < ::Sanitize
11
-
12
- # white-listed elements
13
- ELEMENTS = [
14
- 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'big',
15
- 'blockquote', 'br', 'button', 'caption', 'center', 'cite',
16
- 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir',
17
- 'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'form', 'h1',
18
- 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'input',
19
- 'ins', 'kbd', 'label', 'legend', 'li', 'map', 'menu',
20
- 'ol', 'optgroup', 'option', 'p', 'pre', 'q', 's', 'samp',
21
- 'select', 'small', 'span', 'strike', 'strong', 'sub',
22
- 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th',
23
- 'thead', 'tr', 'tt', 'u', 'ul', 'var'
24
- ].freeze
25
-
26
- # white-listed attributes
27
- ATTRIBUTES = {
28
- 'a' => ['href', 'name', 'data-magellan-destination'],
29
- 'dd' => ['data-magellan-arrival'],
30
- 'dl' => ['data-magellan-expedition'],
31
- 'img' => ['src'],
32
- :all => ['abbr', 'accept', 'accept-charset',
33
- 'accesskey', 'action', 'align', 'alt', 'axis',
34
- 'border', 'cellpadding', 'cellspacing', 'char',
35
- 'charoff', 'class', 'charset', 'checked', 'cite',
36
- 'clear', 'cols', 'colspan', 'color',
37
- 'compact', 'coords', 'datetime', 'dir',
38
- 'disabled', 'enctype', 'for', 'frame',
39
- 'headers', 'height', 'hreflang',
40
- 'hspace', 'id', 'ismap', 'label', 'lang',
41
- 'longdesc', 'maxlength', 'media', 'method',
42
- 'multiple', 'name', 'nohref', 'noshade',
43
- 'nowrap', 'prompt', 'readonly', 'rel', 'rev',
44
- 'rows', 'rowspan', 'rules', 'scope',
45
- 'selected', 'shape', 'size', 'span',
46
- 'start', 'summary', 'tabindex', 'target',
47
- 'title', 'type', 'usemap', 'valign', 'value',
48
- 'vspace', 'width']
49
- }.freeze
50
-
51
- # white-listed protocols
52
- PROTOCOLS = {
53
- 'a' => {'href' => ['http', 'https', 'mailto', 'ftp', 'irc', 'apt', :relative]},
54
- 'img' => {'src' => ['http', 'https', :relative]}
55
- }.freeze
56
-
57
- # elements to remove (incl. contents)
58
- REMOVE_CONTENTS = [
59
- 'script',
60
- 'style'
61
- ].freeze
62
-
63
- # attributes to add to elements
64
- ADD_ATTRIBUTES = {
65
- 'a' => {'rel' => 'nofollow'}
66
- }
67
-
68
- # Creates a new sanitizer with {Spirit}'s configuration.
69
- def initialize
70
- super config
71
- end
72
-
73
- private
74
-
75
- # @return [Hash] configuration hash.
76
- def config
77
- { elements: ELEMENTS.dup,
78
- attributes: ATTRIBUTES.dup,
79
- protocols: PROTOCOLS.dup,
80
- add_attributes: ADD_ATTRIBUTES.dup,
81
- remove_contents: REMOVE_CONTENTS.dup,
82
- allow_comments: false
83
- }
84
- end
85
-
86
- end
87
-
88
- end
89
-
90
- end
@@ -1,5 +0,0 @@
1
- -# coding: UTF-8
2
- %form{id: id}
3
- %input.ex-raw{type: 'hidden', value: raw}
4
- %input.ex-id{type: 'hidden', value: id}
5
- %a.button.run{href: "#"} Run