trekyll 0.1.3 → 0.2.0

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: cd4a95998b1ab11f6393422fe10d457a130619ab
4
- data.tar.gz: 5cacf4ff440001d152d461fe8858fe51e4a865d9
3
+ metadata.gz: 7b54e678739f77ed2785e490a371da0265afd435
4
+ data.tar.gz: 69b21e08a499bb423645cc2baf3b47bd6b4c3dde
5
5
  SHA512:
6
- metadata.gz: 7d4ba0b0f3eed7642c4ba867b15647425af6955f8e4e53119717178ce8fbdb4e198cc14a7da246cb8f4e408ff735088bebdd2f7ceda9c85621ac03ff8869e553
7
- data.tar.gz: '0289cc3b9455564c9d1fb949124b763c1b16ffb528d3592efa185cb852aeac9aeea4bfa5aa3895e48dcafacb8bfbee17f7e27b1194c1bb3eeef21ce97637b30f'
6
+ metadata.gz: ca96a57d46d9cc77063044ea91e0d4f0a3947fcf42d46303a39d02bca1abc5043c56fffb205adce0fd866904150c4ea37a2f5ff2aca7f9ceaac1d27ebdc5f12e
7
+ data.tar.gz: 6e9116577873d7f3f2ba087cf64fca35fb9ef09313764597d42b6defe0881166fd65ac4098075d08a344a4245b9d81ab8d7d6bc3cb31b09ed0a6cce71bfa4f4a
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.4.0 and custom Jekyll themes
5
+ *Note: Currently tested with Jekyll 3.6.0 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.4.0"
17
+ gem "jekyll", "3.6.0"
18
18
 
19
19
  group :jekyll_plugins do
20
20
  gem "jekyll-feed", "~> 0.6"
@@ -1,11 +1,11 @@
1
1
  class String
2
2
  def sanitize_as_page_title
3
- self.gsub(/[^0-9A-Za-z ]/, '')
3
+ self.gsub(/[^[:alnum:] ]/, '').bytes.each_char.select{|c| c.bytes.count < 4 }.join('').gsub('/[#].#\p{L}/','').to_s
4
4
  end
5
5
  def sanitize_as_page_name
6
- self.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(" ",'_')
6
+ self.downcase.gsub(/[^[:alnum:] ]/, '').gsub(" ",'_').unicode_normalize(:nfkd).gsub(/[^\x00-\x7F]/,'')
7
7
  end
8
8
  def sanitize_as_post_name
9
- self.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(" ",'-')
9
+ self.downcase.gsub(/[^[:alnum:] ]/, '').gsub(" ",'-').unicode_normalize(:nfkd).gsub(/[^\x00-\x7F]/,'')
10
10
  end
11
11
  end
@@ -50,7 +50,7 @@ module Trekyll
50
50
 
51
51
  File.open( @nav_dir_name + '/nav.yml', 'a') do |f|
52
52
  # Get substring prefix ##[#] | MyPage_name
53
- i = @page_name.index(/[a-zA-Z]/)
53
+ i = @page_name.index(/[a-zA-Z\p{L}]/)
54
54
  prefix = @page_name[0,i]
55
55
  c = prefix.count("#")
56
56
 
@@ -107,6 +107,49 @@ module Trekyll
107
107
  puts "Page cover image: #{cover_image_url} " if cover_image_url != ""
108
108
  end
109
109
 
110
+
111
+ # TODO: Create Module for Custom Fields: #
112
+ # get_board_fields(board) #
113
+ # get_card_fields(board_fields, card) #
114
+ # get_card_layout(board_fields, card) #
115
+ # #
116
+ # Get card plugin custom fields values (Hash)
117
+ card_field_values = ""
118
+ unless card.plugin_data.nil? then
119
+ card_plugin = card.plugin_data
120
+ card_plugin.each do |plugin|
121
+ plugin.value.map {|k,v| card_field_values = v}
122
+ end
123
+ end
124
+
125
+ # Custom fields for printing in .md file
126
+ custom_fields = ""
127
+ layout = "page"
128
+ unless card.plugin_data.nil? then
129
+ custom_fields = board_custom_fields.map do |field|
130
+ # if field type is: text, number, checkbox, date
131
+ if (0..3) === field["t"]
132
+ "#{field["n"]}: \"#{card_field_values[field["id"]]}\""
133
+ # if field type is: dropdown list
134
+ elsif field["t"] === 4
135
+ # if field name is layout set layout variable
136
+ if field["n"] == "layout"
137
+ drpdwn_id = card_field_values[field["id"]]
138
+ hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
139
+ if hash_with_val != nil
140
+ layout = hash_with_val["value"]
141
+ next
142
+ end
143
+
144
+ else
145
+ drpdwn_id = card_field_values[field["id"]]
146
+ hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
147
+ "#{field["n"]}: \"#{hash_with_val["value"]}\"" if hash_with_val != nil
148
+ end
149
+ end
150
+ end
151
+ end
152
+
110
153
  # Write data to a file
111
154
 
112
155
  page_file = "#{f_name}.md"
@@ -118,13 +161,14 @@ module Trekyll
118
161
 
119
162
  template.puts <<~DOC.gsub(/\t/, '')
120
163
  ---
121
- layout: page
164
+ layout: #{layout}
122
165
  type: #{page_type}
123
- title: "#{page_name.sanitize_as_page_title}"
166
+ title: "#{page_name}"
124
167
  date: #{card.created_at}
125
168
  cover: "#{cover_image_url}"
126
169
  weight: #{counter}
127
170
  permalink: /#{f_name}/
171
+ #{custom_fields.join("\n")}
128
172
  ---
129
173
  DOC
130
174
  template.puts "#{content}"
@@ -230,6 +274,11 @@ module Trekyll
230
274
 
231
275
  end
232
276
 
277
+ # TODO: Create Module for Custom Fields: #
278
+ # get_board_fields(board) #
279
+ # get_card_fields(board_fields, card) #
280
+ # get_card_layout(board_fields, card) #
281
+ # #
233
282
  # Get card plugin custom fields values (Hash)
234
283
  card_field_values = ""
235
284
  unless card.plugin_data.nil? then
@@ -240,15 +289,30 @@ module Trekyll
240
289
  end
241
290
 
242
291
  # Custom fields for printing in .md file
243
- custom_fields = board_custom_fields.map do |field|
244
- # if field type is: text, number, checkbox, date
245
- if (0..3) === field["t"]
246
- "#{field["n"]}: \"#{card_field_values[field["id"]]}\""
247
- # if field type is: dropdown list
248
- elsif field["t"] === 4
249
- drpdwn_id = card_field_values[field["id"]]
250
- hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
251
- "#{field["n"]}: \"#{hash_with_val["value"]}\""
292
+ custom_fields = ""
293
+ layout = "post"
294
+ unless card.plugin_data.nil? then
295
+ custom_fields = board_custom_fields.map do |field|
296
+ # if field type is: text, number, checkbox, date
297
+ if (0..3) === field["t"]
298
+ "#{field["n"]}: \"#{card_field_values[field["id"]]}\""
299
+ # if field type is: dropdown list
300
+ elsif field["t"] === 4
301
+ # if field name is layout set layout variable
302
+ if field["n"] == "layout"
303
+ drpdwn_id = card_field_values[field["id"]]
304
+ hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
305
+ if hash_with_val != nil
306
+ layout = hash_with_val["value"]
307
+ next
308
+ end
309
+
310
+ else
311
+ drpdwn_id = card_field_values[field["id"]]
312
+ hash_with_val = field["o"].find {|element| element["id"] === drpdwn_id}
313
+ "#{field["n"]}: \"#{hash_with_val["value"]}\"" if hash_with_val != nil
314
+ end
315
+ end
252
316
  end
253
317
  end
254
318
 
@@ -260,7 +324,7 @@ module Trekyll
260
324
  #Write data into file
261
325
  template.puts <<~DOC.gsub(/\t/, '')
262
326
  ---
263
- layout: post
327
+ layout: #{layout}
264
328
  cover: "#{cover_image_url}"
265
329
  title: #{card.name}
266
330
  date: #{card.created_at}
@@ -275,4 +339,4 @@ module Trekyll
275
339
  end
276
340
  return true
277
341
  end
278
- end
342
+ end
@@ -1,3 +1,3 @@
1
1
  module Trekyll
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
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-10-03 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trelloapi