deckar01-task_list 2.3.2 → 3.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 811229aaf38f084d46658e2f9a97322546f0888816f97d9c0fdf8644e53547f6
4
- data.tar.gz: 1f246072e4ba01c3e00b194df924d91052621487baf885f6b984c72464ddabae
3
+ metadata.gz: '058afd74f87d80538ead4fff4993788d7f71b1152112edd07115e0554029050c'
4
+ data.tar.gz: 12daa5aca83f2a05ca08f6937b5f7c438ac7a93e6acce53346189fcf25c6814e
5
5
  SHA512:
6
- metadata.gz: 002cd2dd383fe55de9694cd7160dc49af5fa8986a5745d1cc88f9a9507512a092e82af100d53505552ddc135fe399de120abc4ddf1b4876064482cdca9eae77f
7
- data.tar.gz: 10f495655ec32696adca0ba524c8790163c52ca27a5b57f11b277dcf6fbf5c14cfc3766db803cfe4691af9b49f072783448f7f8cbb3637a94d1612cc9a9abd74
6
+ metadata.gz: 7578ca24199c41c957baab771a76f2f7d605bf9d128ff461fffa618700aca615d29c5128b4ffb2b40b251fc7bbf5ed19ec49dd9b44a87b654dd6a15fc78f433d
7
+ data.tar.gz: bc47cc0071775b370fc3a26e232d6121c4aff312579c9879c428437d1af8b46d14dfdb4bd9e22378d9cbcb363bd513e72c21590bb545e0f5c12af588de1131e6
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ tmp
19
19
  bower_components
20
20
  node_modules
21
21
  vendor/gems/
22
+ vendor/bundle/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,22 @@
1
+ .test: &test
2
+ stage: test
3
+ before_script:
4
+ - ./script/bootstrap
5
+ script:
6
+ - ./script/cibuild
7
+
8
+ test 3.0:
9
+ image: "ruby:3.0"
10
+ <<: *test
11
+
12
+ test 3.1:
13
+ image: "ruby:3.1"
14
+ <<: *test
15
+
16
+ test 3.2:
17
+ image: "ruby:3.2"
18
+ <<: *test
19
+
20
+ test 3.3:
21
+ image: "ruby:3.3-rc"
22
+ <<: *test
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Task Lists
2
2
 
3
- [![Build Status](http://img.shields.io/travis/deckar01/task_list.svg)][travis]
4
-
5
- [travis]: https://travis-ci.org/deckar01/task_list
3
+ [![pipeline status](https://gitlab.com/deckar01/task_list/badges/master/pipeline.svg)](https://gitlab.com/deckar01/task_list/-/commits/master)
6
4
 
7
5
  This is a community fork of GitHub's archived [`task_list`][task_list] gem.
8
6
 
@@ -85,7 +83,7 @@ NOTE: Updates are not persisted to the server automatically. Persistence is the
85
83
 
86
84
  Read through the documented behaviors and samples [in the source][frontend_behaviors] for more detail, including documented events.
87
85
 
88
- [frontend_behaviors]: https://github.com/deckar01/task_list/blob/master/app/assets/javascripts/task_list.coffee
86
+ [frontend_behaviors]: https://gitlab.com/deckar01/task_list/blob/master/app/assets/javascripts/task_list.coffee
89
87
 
90
88
  ## Installation
91
89
 
data/bower.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "deckar01-task_list",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "Markdown TaskList components",
5
- "homepage": "https://github.com/deckar01/task_list",
5
+ "homepage": "https://gitlab.com/deckar01/task_list",
6
6
  "devDependencies": {
7
7
  "jquery": ">= 1.9.1 <3",
8
- "qunit": "^1.0.0",
9
8
  "rails-behaviors": "^0.8.4"
10
9
  },
11
10
  "main": [
data/build.mjs ADDED
@@ -0,0 +1,26 @@
1
+ import { build } from 'esbuild';
2
+ import coffeeScriptPlugin from 'esbuild-coffeescript';
3
+ import { umdWrapper } from 'esbuild-plugin-umd-wrapper';
4
+
5
+ await build({
6
+ entryPoints: ['app/assets/javascripts/task_list.coffee'],
7
+ bundle: true,
8
+ minify: true,
9
+ format: 'umd',
10
+ outfile: 'dist/task_list.js',
11
+ plugins: [
12
+ coffeeScriptPlugin(),
13
+ umdWrapper({libraryName: 'TaskList'}),
14
+ ],
15
+ logLevel: 'info',
16
+ });
17
+
18
+ await build({
19
+ entryPoints: ['test/unit/*.coffee'],
20
+ bundle: true,
21
+ outdir: 'bin/test/unit/',
22
+ plugins: [
23
+ coffeeScriptPlugin(),
24
+ ],
25
+ logLevel: 'info',
26
+ });
@@ -37,30 +37,20 @@ class TaskList
37
37
  IncompletePattern = /\[[[:space:]]\]/.freeze # matches all whitespace
38
38
  CompletePattern = /\[[xX]\]/.freeze # matches any capitalization
39
39
 
40
+ # All valid checkbox patterns.
41
+ # Useful for overriding ItemPattern wih custom formats.
42
+ CheckboxPatterns = /#{CompletePattern}|#{IncompletePattern}/
43
+
40
44
  # Pattern used to identify all task list items.
41
45
  # Useful when you need iterate over all items.
42
46
  ItemPattern = /
43
47
  ^
44
48
  (?:\s*[-+*]|(?:\d+\.))? # optional list prefix
45
49
  \s* # optional whitespace prefix
46
- ( # checkbox
47
- #{CompletePattern}|
48
- #{IncompletePattern}
49
- )
50
+ (#{CheckboxPatterns}) # checkbox
50
51
  (?=\s) # followed by whitespace
51
52
  /x
52
53
 
53
- ListItemSelector = ".//li[task_list_item(.)]".freeze
54
-
55
- class XPathSelectorFunction
56
- def self.task_list_item(nodes)
57
- nodes.select { |node| node.text =~ ItemPattern }
58
- end
59
- end
60
-
61
- # Selects first P tag of an LI, if present
62
- ItemParaSelector = "./p[1]".freeze
63
-
64
54
  # List of `TaskList::Item` objects that were recognized in the document.
65
55
  # This is available in the result hash as `:task_list_items`.
66
56
  #
@@ -69,13 +59,20 @@ class TaskList
69
59
  result[:task_list_items] ||= []
70
60
  end
71
61
 
62
+ # Computes attributes for the item input.
63
+ #
64
+ # Returns an String of HTML attributes.
65
+ def checkbox_attributes(item)
66
+ 'checked="checked"' if item.complete?
67
+ end
68
+
72
69
  # Renders the item checkbox in a span including the item state.
73
70
  #
74
71
  # Returns an HTML-safe String.
75
72
  def render_item_checkbox(item)
76
73
  %(<input type="checkbox"
77
74
  class="task-list-item-checkbox"
78
- #{'checked="checked"' if item.complete?}
75
+ #{checkbox_attributes(item)}
79
76
  disabled="disabled"
80
77
  />)
81
78
  end
@@ -95,15 +92,6 @@ class TaskList
95
92
  item.source.sub(ItemPattern, render_item_checkbox(item)), 'utf-8'
96
93
  end
97
94
 
98
- # Public: Select all task list items within `container`.
99
- #
100
- # Returns an Array of Nokogiri::XML::Element objects for ordered and
101
- # unordered lists. The container can either be the entire document (as
102
- # returned by `#doc`) or an Element object.
103
- def list_items(container)
104
- container.xpath(ListItemSelector, XPathSelectorFunction)
105
- end
106
-
107
95
  # Filters the source for task list items.
108
96
  #
109
97
  # Each item is wrapped in HTML to identify, style, and layer
@@ -113,25 +101,15 @@ class TaskList
113
101
  #
114
102
  # Returns nothing.
115
103
  def filter!
116
- list_items(doc).reverse.each do |li|
117
- next if list_items(li.parent).empty?
118
-
119
- add_css_class(li.parent, 'task-list')
120
-
121
- outer, inner =
122
- if p = li.xpath(ItemParaSelector)[0]
123
- [p, p.inner_html]
124
- else
125
- [li, li.inner_html]
126
- end
127
- if match = (inner.chomp =~ ItemPattern && $1)
128
- item = TaskList::Item.new(match, inner)
129
- # prepend because we're iterating in reverse
130
- task_list_items.unshift item
131
-
132
- add_css_class(li, 'task-list-item')
133
- outer.inner_html = render_task_list_item(item)
134
- end
104
+ doc.xpath(".//li").reverse.each do |li|
105
+ container = li.xpath("./p[1]")[0] || li
106
+ next if not container.inner_html =~ ItemPattern
107
+
108
+ item = TaskList::Item.new($1, container.inner_html)
109
+ task_list_items.unshift item
110
+ container.inner_html = render_task_list_item(item)
111
+ li.parent.add_class('task-list')
112
+ li.add_class('task-list-item')
135
113
  end
136
114
  end
137
115
 
@@ -139,14 +117,5 @@ class TaskList
139
117
  filter!
140
118
  doc
141
119
  end
142
-
143
- # Private: adds a CSS class name to a node, respecting existing class
144
- # names.
145
- def add_css_class(node, *new_class_names)
146
- class_names = (node['class'] || '').split(' ')
147
- return if new_class_names.all? { |klass| class_names.include?(klass) }
148
- class_names.concat(new_class_names)
149
- node['class'] = class_names.uniq.join(' ')
150
- end
151
120
  end
152
121
  end
@@ -1,3 +1,3 @@
1
1
  class TaskList
2
- VERSION = [2, 3, 2].join('.')
2
+ VERSION = [3, 0, 'alpha1'].join('.')
3
3
  end