trekyll 0.2.1 → 0.3.1

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
  SHA1:
3
- metadata.gz: '09789f5453e5d4d496e9c9a68820e4586375cdfe'
4
- data.tar.gz: 156b3ed3a50f16f2ebec2028aecf87c9a1881ce3
3
+ metadata.gz: 943e9309aa462c9c9421eec588ac5cf964eac7f4
4
+ data.tar.gz: 1ad1b597edd5e38230c1e07f14710fa3532ecf9f
5
5
  SHA512:
6
- metadata.gz: f7ee1c3767cb4443220923df42d768ed56711d45db29781f37bd49760d37cc79420bdf88d64b1762fd730a5a54d82078c52912f7eda8d0d0d9a41051de6504c9
7
- data.tar.gz: 16351a0adcd07d3d1741a4baf2d377fb553bcd142602ec4eaa139d6147406796842fae2fd4ee855a6fecbf563e0b24ed0309a6404ec70f0ffff6105099d06715
6
+ metadata.gz: 115f5d2cbe801db9c83ecbb621137631f0a0f1b266b464ca9941063c8fa2c8ac5f3a22a11d072eea4ee82f170c042fa82ab2ff5246c54874fe75d25ad90608aa
7
+ data.tar.gz: 7753f8023ffecd5a8b30b07abda23928136920acc7234d79c13021425d7666b3109ff6401300f56a0b01562cc35395f27408995495d976cd37b8fb093cf0c561
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Welcome to Trekyll. Trekyll is Jekyll plugin which enables you to use Trello board as CMS backend.
4
4
 
5
- *Note: Currently tested with Jekyll 3.6.0 and custom Jekyll themes
5
+ *Note: Currently tested with Jekyll 3.8.4 and custom Jekyll themes
6
6
 
7
7
  ## Installation:
8
8
 
@@ -14,7 +14,7 @@ Copy this code and save it as "Gemfile":
14
14
  source "https://rubygems.org"
15
15
  ruby RUBY_VERSION
16
16
 
17
- gem "jekyll", "3.6.0"
17
+ gem "jekyll", "3.8.4"
18
18
 
19
19
  group :jekyll_plugins do
20
20
  gem "jekyll-feed", "~> 0.6"
@@ -0,0 +1,75 @@
1
+ require 'trello'
2
+
3
+ # @board_custom_fields are JSON "customFields" | trello-api board.custom_fields
4
+ #
5
+ # @card_field_values are JSON cards: "customFieldItems" | trello-api card.custom_field_items
6
+ #
7
+ # @lyt is layout expectation eg. page, post
8
+ #
9
+ module Trekyll
10
+ class CustomFieldsManager
11
+
12
+ def initialize
13
+ end
14
+
15
+ def get_fields_and_layout(board_custom_fields, card_field_values, lyt)
16
+ fields_list = ""
17
+ layout = lyt
18
+ fields_list = board_custom_fields.map do |field|
19
+
20
+ f_type = field.type
21
+ val = ""
22
+ # if field type is list
23
+ if f_type == 'list'
24
+
25
+ if field.name == 'layout'
26
+ card_field_values.each do |cf|
27
+ if cf.custom_field_id == field.id and cf.option_id != nil
28
+ el = field.custom_field_options.find {|element| element.id == cf.option_id}
29
+ layout = el.value["text"]
30
+ end
31
+ end
32
+ else
33
+
34
+ card_field_values.each do |cf|
35
+ if cf.custom_field_id == field.id and cf.option_id != nil
36
+ el = field.custom_field_options.find {|element| element.id == cf.option_id}
37
+ val = el.value["text"]
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ # return value if not layout
44
+ ### empty layout: "" jekyll 3.8.4 bugfix
45
+ if field.name != 'layout'
46
+ "#{field.name}: \"#{val}\""
47
+ else
48
+ ""
49
+ end
50
+
51
+ # if field type checkbox
52
+ elsif f_type == 'checkbox'
53
+ card_field_values.each do |cf|
54
+ if cf.custom_field_id == field.id and cf.value != nil
55
+ val = cf.value["checked"]
56
+ end
57
+ end
58
+ "#{field.name}: \"#{val}\""
59
+
60
+ # if field type text, number, date
61
+ else
62
+ card_field_values.each do |cf|
63
+ if cf.custom_field_id == field.id and cf.value != nil
64
+ val = cf.value[f_type.to_s]
65
+ end
66
+ end
67
+ "#{field.name}: \"#{val}\""
68
+ end
69
+
70
+ end
71
+ return fields_list , layout
72
+ end
73
+
74
+ end
75
+ end
@@ -6,6 +6,7 @@ require_relative 'configurator'
6
6
  require_relative 'navigation_manager'
7
7
  require_relative 'core_ext/string'
8
8
  require_relative 'filemanager'
9
+ require_relative 'customfieldsmanager'
9
10
 
10
11
  module Trekyll
11
12
  def self.start_trekyll
@@ -27,6 +28,8 @@ module Trekyll
27
28
  config.member_token = init_config.token
28
29
  end
29
30
 
31
+ #Custom Fields Plugin Manager
32
+ cfm = CustomFieldsManager.new
30
33
 
31
34
  # Test trello connection
32
35
  user = Trello::Member.find("mucicnenad")
@@ -50,14 +53,9 @@ module Trekyll
50
53
  lists = board.lists
51
54
  board_custom_fields = ""
52
55
 
53
- # Get board plugin fields
54
- unless board.plugin_data.nil? then
55
- plugins = board.plugin_data
56
- plugins.each do |plugin|
57
- plugin.value.map {|k,fields|
58
- board_custom_fields = fields
59
- }
60
- end
56
+ # Get board custom fields
57
+ unless board.custom_fields.nil? then
58
+ board_custom_fields = board.custom_fields
61
59
  end
62
60
 
63
61
  counter = 1
@@ -109,47 +107,15 @@ module Trekyll
109
107
  puts "Page cover image: #{cover_image_url} " if cover_image_url != ""
110
108
  end
111
109
 
112
-
113
- # TODO: Create Module for Custom Fields: #
114
- # get_board_fields(board) #
115
- # get_card_fields(board_fields, card) #
116
- # get_card_layout(board_fields, card) #
117
110
  # #
118
- # Get card plugin custom fields values (Hash)
119
- card_field_values = ""
120
- unless card.plugin_data.nil? then
121
- card_plugin = card.plugin_data
122
- card_plugin.each do |plugin|
123
- plugin.value.map {|k,v| card_field_values = v}
124
- end
125
- end
111
+ # cfm.get_fields_and_layout(board_fields, card_fields, layout) #
112
+ # #
126
113
 
127
114
  # Custom fields for printing in .md file
128
115
  custom_fields = ""
129
116
  layout = "page"
130
- unless card.plugin_data.nil? then
131
- custom_fields = board_custom_fields.map do |field|
132
- # if field type is: text, number, checkbox, date
133
- if (0..3) === field["t"]
134
- "#{field["n"]}: \"#{card_field_values[field["id"]]}\""
135
- # if field type is: dropdown list
136
- elsif field["t"] === 4
137
- # if field name is layout set layout variable
138
- if field["n"] == "layout"
139
- drpdwn_id = card_field_values[field["id"]]
140
- hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
141
- if hash_with_val != nil
142
- layout = hash_with_val["value"]
143
- next
144
- end
145
-
146
- else
147
- drpdwn_id = card_field_values[field["id"]]
148
- hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
149
- "#{field["n"]}: \"#{hash_with_val["value"]}\"" if hash_with_val != nil
150
- end
151
- end
152
- end
117
+ unless card.custom_field_items.nil? then
118
+ custom_fields, layout = cfm.get_fields_and_layout(board_custom_fields, card.custom_field_items, layout)
153
119
  end
154
120
 
155
121
  # Write data to a file
@@ -291,46 +257,12 @@ module Trekyll
291
257
 
292
258
  end
293
259
 
294
- # TODO: Create Module for Custom Fields: #
295
- # get_board_fields(board) #
296
- # get_card_fields(board_fields, card) #
297
- # get_card_layout(board_fields, card) #
298
- # #
299
- # Get card plugin custom fields values (Hash)
300
- card_field_values = ""
301
- unless card.plugin_data.nil? then
302
- card_plugin = card.plugin_data
303
- card_plugin.each do |plugin|
304
- plugin.value.map {|k,v| card_field_values = v}
305
- end
306
- end
307
260
 
308
261
  # Custom fields for printing in .md file
309
262
  custom_fields = ""
310
263
  layout = "post"
311
- unless card.plugin_data.nil? then
312
- custom_fields = board_custom_fields.map do |field|
313
- # if field type is: text, number, checkbox, date
314
- if (0..3) === field["t"]
315
- "#{field["n"]}: \"#{card_field_values[field["id"]]}\""
316
- # if field type is: dropdown list
317
- elsif field["t"] === 4
318
- # if field name is layout set layout variable
319
- if field["n"] == "layout"
320
- drpdwn_id = card_field_values[field["id"]]
321
- hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
322
- if hash_with_val != nil
323
- layout = hash_with_val["value"]
324
- next
325
- end
326
-
327
- else
328
- drpdwn_id = card_field_values[field["id"]]
329
- hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
330
- "#{field["n"]}: \"#{hash_with_val["value"]}\"" if hash_with_val != nil
331
- end
332
- end
333
- end
264
+ unless card.custom_field_items.nil? then
265
+ custom_fields, layout = cfm.get_fields_and_layout(board_custom_fields, card.custom_field_items, layout)
334
266
  end
335
267
 
336
268
  #get widget selector from card content and replace with liquid
@@ -1,3 +1,3 @@
1
1
  module Trekyll
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
data/trekyll.gemspec CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  # TO DO: Set ruby-trello to my github (until the changes get in 2.1.0 v)
34
- spec.add_runtime_dependency "trelloapi",">= 0.0.0"
35
- # spec.add_runtime_dependency "ruby-trello",">= 2.0.0"
34
+ # spec.add_runtime_dependency "trelloapi",">= 0.0.0"
35
+ spec.add_runtime_dependency "ruby-trello",">= 2.1.0"
36
36
  spec.add_runtime_dependency "indentation", "~> 0.1.1"
37
37
 
38
38
  # spec.add_development_dependency "bundler", "~> 1.14"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Canic Interactive
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-15 00:00:00.000000000 Z
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: trelloapi
14
+ name: ruby-trello
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.0
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.0
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: indentation
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +63,7 @@ files:
63
63
  - lib/trekyll.rb
64
64
  - lib/trekyll/configurator.rb
65
65
  - lib/trekyll/core_ext/string.rb
66
+ - lib/trekyll/customfieldsmanager.rb
66
67
  - lib/trekyll/filemanager.rb
67
68
  - lib/trekyll/initializator.rb
68
69
  - lib/trekyll/navigation_manager.rb