trekyll 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2201839245d853479ae918423539b37c507a5bbc
4
+ data.tar.gz: fd0a2fa900e2c9d9c3818ff80317380e830c1fc3
5
+ SHA512:
6
+ metadata.gz: 2c23ea313692d8bd73b774cd769889ee3d694bb99839550cfad6ae2fd083067fb36f17bf61b742490c10af25ef8ff3e2abcef36141fba0de168f642afdf75a62
7
+ data.tar.gz: 5bf6b469f36b35233f83a41331743bef3d7ed8ccb0bb7509e596bfbb529920bb1a62bf941380e462b65cd1b51555c0795bd03e90e41c557edfccd5b4829c706b
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trekyll.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Canic Interactive LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Trekyll
2
+
3
+ Welcome to Trekyll. Trekyll is Jekyll plugin which enables you to use Trello board as CMS backend.
4
+
5
+ *Note: Currently tested with Jekyll 3.4.0 and custom Jekyll themes
6
+
7
+ ## Installation:
8
+
9
+ ### Option A (bundled with Jekyll)
10
+
11
+ Copy this code and save it as "Gemfile":
12
+
13
+ ```
14
+ source "https://rubygems.org"
15
+ ruby RUBY_VERSION
16
+
17
+ gem "jekyll", "3.4.0"
18
+
19
+ group :jekyll_plugins do
20
+ gem "jekyll-feed", "~> 0.6"
21
+ end
22
+
23
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
24
+ gem "trekyll",">=0.0.0"
25
+ ```
26
+
27
+ Navigate to folder with the Gemfile and then run
28
+
29
+ ```ruby
30
+ $ bundle install
31
+ ```
32
+
33
+
34
+ ### Option B (On top of existing Jekyll 3.4.0)
35
+ **With bundler - ** Add this line to your application's "Gemfile":
36
+
37
+ ```ruby
38
+ gem 'trekyll'
39
+ ```
40
+
41
+ And then execute:
42
+
43
+ $ bundle
44
+
45
+ **Without bundler - ** Just install gem:
46
+
47
+ $ gem install trekyll
48
+
49
+ ## Usage in project
50
+ First thing first:
51
+
52
+ Make your new jekyll project
53
+
54
+ $ jekyll new my_project
55
+
56
+ cd in your newly created project
57
+
58
+ $ cd my_project
59
+
60
+ then open Gemfile and add this gem requirement
61
+
62
+ ```ruby
63
+ gem 'trekyll'
64
+ ```
65
+
66
+ Initialize your project
67
+
68
+ $ trekyll init
69
+
70
+
71
+ ***Setup your credentials for Trello:***
72
+
73
+ 1. Login to your Trello account.
74
+ 2. Open newly created **_init.yml** and paste your public key and member token from:
75
+
76
+ ```
77
+ $ irb
78
+ $ irb> require 'trello'
79
+ $ irb> Trello.open_public_key_url # copy your public key
80
+ $ irb> Trello.open_authorization_url key: 'yourpublickey' # copy your member token
81
+ $ irb> exit
82
+ ```
83
+
84
+ Enter your Board name and prefered Lists, and you are good to go
85
+
86
+ **Get data from trello**
87
+
88
+ $ trekyll get
89
+
90
+ ## Trekyll commands overview
91
+
92
+ ###Help message about Trekyll
93
+
94
+ $ trekyll
95
+ $ trekyll -h
96
+ $ trekyll --help
97
+
98
+ ###Initialize your project
99
+ $ trekyll init
100
+
101
+ ###Get data from Trello board
102
+ $ trekyll get
103
+
104
+ ## License
105
+
106
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
107
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trekyll"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ # Welcome to Jekyll (Trekyll)!
2
+ #
3
+ # This config file is meant for settings that affect your whole blog, values
4
+ # which you are expected to set up once and rarely edit after that. If you find
5
+ # yourself editing this file very often, consider using Jekyll's data files
6
+ # feature for the data you need to update frequently.
7
+ #
8
+ # For technical reasons, this file is *NOT* reloaded automatically when you use
9
+ # 'bundle exec jekyll serve'. If you change this file, please restart the server process.
10
+
11
+ # Site settings
12
+ # These are used to personalize your new site. If you look in the HTML files,
13
+ # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
14
+ # You can create any custom variable you would like, and they will be accessible
15
+ # in the templates via {{ site.myvariable }}.
16
+ title: Trekyll CMS
17
+ email: trekyll@canicinteractive.com
18
+ description: > # this means to ignore newlines until "baseurl:"
19
+ Trekyll is an awesome formula that mixes static site generator and management - collaboration platform
20
+ (<span class="am">Tre</span>llo + Je<span class="am">kyll) = <span class="am">Trekyll</span>.
21
+ baseurl: "" # the subpath of your site, e.g. /blog
22
+ url: "" # the base hostname & protocol for your site, e.g. http://example.com
23
+ twitter_username: trekyll
24
+ github_username: trekyll
25
+ excerpt_separator: <!-- more -->
26
+
27
+ # Build settings
28
+ markdown: kramdown
29
+ theme: minima # TO DO: Change to Our base theme
30
+ gems:
31
+ - jekyll-feed
32
+ exclude:
33
+ - Gemfile
34
+ - Gemfile.lock
35
+
36
+ #Custom settings
37
+ collections:
38
+ - widgets
39
+ - blocks
@@ -0,0 +1,31 @@
1
+ # TO DO:
2
+ # Welcome ...
3
+
4
+ # How to get your trello public key nad member token:
5
+
6
+ # Get your API public key from Trello via the irb console:
7
+ # In yor console open irb
8
+ # $ irb
9
+ # irb> require 'trello'
10
+ # irb> Trello.open_public_key_url # copy your public key
11
+ # irb> Trello.open_authorization_url key: 'yourpublickey' # copy your member token
12
+
13
+ # Paste in your public key and member token:
14
+ developer_public_key:
15
+ member_token:
16
+
17
+ # Trello Board name
18
+ board: Playground
19
+
20
+ # Trello List name for:
21
+
22
+ # List containing Pages
23
+ pages: Pages
24
+
25
+ # List containing Posts. It allows multiple lists (every list name corresponds to a category name)
26
+ posts: News, Blog
27
+ widgets: Widgets
28
+ blocks: "[*Blocks*]"
29
+
30
+ # List name containing navigation (if omitted navigation will be created from Pages list)
31
+ # navigation: Navigation
data/exe/trekyll ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trekyll"
5
+
6
+ Trekyll::command_interpretter(ARGV[0])
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,39 @@
1
+ require 'YAML'
2
+
3
+ module Trekyll
4
+ class TrekyllConfigurator
5
+
6
+ INIT_CONFIGURABLE_ATTRIBUTES = [
7
+ :key,
8
+ :token,
9
+ :board,
10
+ :pages,
11
+ :posts,
12
+ :widgets,
13
+ :blocks,
14
+ :navigation
15
+ ]
16
+ attr_accessor *INIT_CONFIGURABLE_ATTRIBUTES
17
+
18
+ # constructor
19
+ def initialize()
20
+ config = ""
21
+
22
+ if File.file?('_init.yml')
23
+ config = YAML.load_file('_init.yml')
24
+ else
25
+ puts "OHhh there is no '_init.yml' file in your project !!! "
26
+ end
27
+
28
+ @key = config['developer_public_key']
29
+ @token = config['member_token']
30
+ @board = config['board']
31
+ @pages = config['pages']
32
+ @posts = config['posts']
33
+ @widgets = config['widgets']
34
+ @blocks = config['blocks']
35
+ @navigation = config['navigation']
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ class String
2
+ def sanitize_as_page_title
3
+ self.gsub(/[^0-9A-Za-z ]/, '')
4
+ end
5
+ def sanitize_as_page_name
6
+ self.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(" ",'_')
7
+ end
8
+ def sanitize_as_post_name
9
+ self.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(" ",'-')
10
+ end
11
+ end
@@ -0,0 +1,74 @@
1
+ require 'pathname'
2
+ require 'fileutils'
3
+
4
+ module Trekyll
5
+ class TrekyllFileManager
6
+
7
+ # Defoult directory structure
8
+ DIR_DEFAULTS = {
9
+ # "source" => Dir.pwd,
10
+ "data_dir" => "_data",
11
+ "widgets_dir" => "_widgets",
12
+ "posts_dir" => "_posts",
13
+ "blocks_dir" => "_blocks"
14
+ }
15
+
16
+ # Defoult file structure
17
+ FILE_DEFAULTS = {
18
+ "_data" => "nav.yml"
19
+ }
20
+
21
+ # Constructor (meta-programming approach) with dinamic attribute-property getter/setter methods
22
+ # based on hash values
23
+
24
+ # Adding new attribute => value in DIR_DEFOULTS this constructor creates
25
+ # getter and setter method for newly entered property (directory)
26
+ def initialize()
27
+
28
+ DIR_DEFAULTS.map{ |attribute_name, attribute_value|
29
+
30
+ self.class.send(:define_method, "#{attribute_name}=".to_sym) do |value|
31
+ instance_variable_set("@" + attribute_name.to_s, value)
32
+ end
33
+
34
+ self.class.send(:define_method, attribute_name.to_sym) do
35
+ instance_variable_get("@" + attribute_name.to_s)
36
+ end
37
+
38
+ self.send("#{attribute_name}=".to_sym, attribute_value)
39
+
40
+ }
41
+ end
42
+
43
+ def delete_file_struct
44
+ # Clear all existing md files except index.md
45
+ Dir.glob( Dir.pwd + '/*.md').each do |file|
46
+ if file != Dir.pwd + "/index.md"
47
+ File.delete(file)
48
+ end
49
+ end
50
+ puts "+++++ Trekyll is: +++++"
51
+ puts "** Flushing old data **"
52
+
53
+ # Clear dir structure
54
+ DIR_DEFAULTS.map{ |k,dir_name| FileUtils.rm_rf(dir_name) }
55
+ end
56
+
57
+ def create_file_struct
58
+ #Create directories
59
+ DIR_DEFAULTS.map { |k,dir|
60
+ dirname = File.dirname(dir + "/empty")
61
+ puts "Creating dir: #{dirname}"
62
+ unless File.directory?(dirname)
63
+ FileUtils::mkdir_p(dirname)
64
+ end
65
+ }
66
+ # Create files in correspondin directories
67
+ FILE_DEFAULTS.map { |dir,file|
68
+ puts "Creating file: #{file}"
69
+ File.new(dir + "/" + file, 'w')
70
+ }
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,13 @@
1
+ require 'fileutils'
2
+
3
+ module Trekyll
4
+ class TemplateFilesInit
5
+ def initialize
6
+ end
7
+ def templates_init
8
+ trekyll_template = File.expand_path('../../config_templates',File.dirname(__FILE__))
9
+ local_dir = Dir.pwd
10
+ FileUtils.cp_r trekyll_template + "/.", local_dir
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,90 @@
1
+ require 'pathname'
2
+ require 'fileutils'
3
+ require 'indentation'
4
+ require_relative 'core_ext/string'
5
+
6
+ module Trekyll
7
+
8
+ # Navigation Manager gets as imputs:
9
+ # @page_name ( String with/without "prefix" )
10
+ # @nav_dir_name ( name of directory with nav.yml file ) eg. _data/nav.yml
11
+
12
+ # Navigation Manager sets as outputs:
13
+ # @page_file_name ( sanitized page name for href/url creation )
14
+ # @page_name ( String without "prefix" )
15
+ # @page_type ( page/subpage )
16
+
17
+ # Prefix definition:
18
+ # [#] - Container
19
+ # # - Sub page
20
+ # #[#] - Sub page conainer
21
+ # ## - Sub sub page
22
+ # ##[#] - Sub sub container page
23
+ # ### - Sub sub sub page
24
+ # [/#] - Container with ommited page url (links to homepage when clicked)
25
+ # [!] - Ommited page from navigation
26
+
27
+ class NavigationManager
28
+
29
+ CONFIGURABLE_PROPERTIES = [
30
+ :page_name,
31
+ :page_type,
32
+ :nav_dir_name,
33
+ :page_file_name
34
+ ]
35
+
36
+ attr_accessor *CONFIGURABLE_PROPERTIES
37
+
38
+ # constructor *( defoult navigation location _data dir)
39
+ def initialize(dir="_data")
40
+ @nav_dir_name = dir
41
+ end
42
+
43
+ # Add page to nav.yml
44
+ def add_page(page)
45
+ # get page name
46
+ @page_name = page
47
+
48
+ # create a file name (remove special chars and convert spaces to "_")
49
+ @page_file_name = @page_name.sanitize_as_page_name
50
+
51
+ File.open( @nav_dir_name + '/nav.yml', 'a') do |f|
52
+ # Get substring prefix ##[#] | MyPage_name
53
+ i = @page_name.index(/[a-zA-Z]/)
54
+ prefix = @page_name[0,i]
55
+ c = prefix.count("#")
56
+
57
+ # Define different spacing for first # and odd numbr of # (hashes)
58
+ if c == 1
59
+ c = 0
60
+ elsif c % 2 != 0
61
+ c = c+1
62
+ end
63
+
64
+ if prefix.include?("[#]")
65
+ f.puts "- title: \"#{@page_name.sub!(prefix,'')}\" ".indent(c)
66
+ f.puts " href: /#{@page_file_name}/".indent(c)
67
+ f.puts " subcategories:".indent(c)
68
+ @page_type = "page"
69
+
70
+ elsif prefix.include?("[/#]")
71
+ f.puts "- title: \"#{@page_name.sub!(prefix,'')}\" ".indent(c)
72
+ f.puts " subcategories:".indent(c)
73
+ @page_type = "page"
74
+
75
+ elsif prefix.include?("#")
76
+ f.puts "- title: \"#{@page_name.sub!(prefix,'')}\" ".indent(c+2)
77
+ f.puts " href: /#{@page_file_name}/".indent(c+2)
78
+ @page_type = "subpage"
79
+
80
+ elsif @page_name.start_with?("[!]")
81
+ @page_name.sub!(prefix,"")
82
+ else
83
+ f.puts "- title: \"#{page_name}\" "
84
+ f.puts " href: /#{page_file_name}/"
85
+ @page_type = "page"
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,226 @@
1
+ require 'trello'
2
+ require 'pathname'
3
+ require 'fileutils'
4
+
5
+ require_relative 'configurator'
6
+ require_relative 'navigation_manager'
7
+ require_relative 'core_ext/string'
8
+ require_relative 'filemanager'
9
+
10
+ module Trekyll
11
+ def self.start_trekyll
12
+ # Define start file and folder structure #
13
+ f_manager = TrekyllFileManager.new
14
+
15
+ f_manager.delete_file_struct()
16
+ f_manager.create_file_struct()
17
+
18
+ # Get configuration from _init.yml
19
+ init_config = TrekyllConfigurator.new
20
+
21
+ # Create navigation manager object
22
+ navigation = NavigationManager.new(f_manager.data_dir)
23
+
24
+ # Configure trello connection
25
+ Trello.configure do |config|
26
+ config.developer_public_key = init_config.key
27
+ config.member_token = init_config.token
28
+ end
29
+
30
+
31
+ # Test trello connection
32
+ user = Trello::Member.find("mucicnenad")
33
+ puts "********************"
34
+ # Print user name
35
+ puts "*** #{user.full_name}! ***"
36
+ # Print user bio
37
+ puts "* #{user.bio} *"
38
+ puts "********************"
39
+
40
+ board_name = init_config.board
41
+
42
+ board = Trello::Board.all.find { |b| b.name == board_name }
43
+
44
+ if board.nil?
45
+ abort "Unable to find board named: #{board_name}"
46
+ end
47
+
48
+ # Globals
49
+ cards = board.cards
50
+ lists = board.lists
51
+
52
+
53
+ counter = 1
54
+ cards.each do |card|
55
+
56
+ # Create Navigation if navigation list name is defined in _nav.yml
57
+ if card.list.name == init_config.navigation then
58
+ page_name = card.name
59
+ navigation.add_page(page_name)
60
+
61
+ # Create pages from Pages List
62
+ elsif card.list.name == init_config.pages then
63
+
64
+ page_name = card.name
65
+
66
+ #create a file name (remove special chars and convert spaces to _ )
67
+ f_name = page_name.sanitize_as_page_name
68
+
69
+ # page type indentificator
70
+ page_type = "" # page, subpage ..
71
+
72
+ #get widget selector from card content and replace with liquid
73
+ content = card.desc.gsub('[>','{{site.widgets| where: "name","')
74
+ content = content.gsub('<]','"}}')
75
+
76
+ # If navigation List is not set in _init.yml
77
+ # create navigation from pages
78
+ if init_config.navigation.nil? then
79
+
80
+ navigation.add_page(page_name)
81
+ page_type = navigation.page_type
82
+ page_name = navigation.page_name
83
+ f_name = navigation.page_file_name
84
+
85
+ end
86
+
87
+ # Get cover image
88
+ cover_id = card.cover_image_id
89
+ cover_image_url = ""
90
+ unless card.attachments.nil? then
91
+ card.attachments.each do |attachment|
92
+ if attachment.id == cover_id
93
+ cover_image_url = attachment.url
94
+ end
95
+ end
96
+ puts "Page cover image: #{cover_image_url} " if cover_image_url != ""
97
+ end
98
+
99
+ # Write data to a file
100
+
101
+ page_file = "#{f_name}.md"
102
+
103
+ puts "Creating file: #{page_file}"
104
+
105
+ # Page template
106
+ template = File.open page_file, "w"
107
+
108
+ template.puts <<~DOC.gsub(/\t/, '')
109
+ ---
110
+ layout: page
111
+ type: #{page_type}
112
+ title: "#{page_name.sanitize_as_page_title}"
113
+ date: #{card.created_at}
114
+ header: "#{cover_image_url}"
115
+ weight: #{counter}
116
+ permalink: /#{f_name}/
117
+ ---
118
+ DOC
119
+ template.puts "#{content}"
120
+ template.close
121
+ counter = counter.next
122
+
123
+ # Create Widgets
124
+ elsif card.list.name == init_config.widgets then
125
+
126
+ #get widgets dir name from file manager config
127
+ dir_name = f_manager.widgets_dir
128
+ f_name = card.name.sanitize_as_page_name
129
+ widget_name = "#{f_name}.md"
130
+
131
+ template = File.open(File.join(Dir.pwd, dir_name, widget_name),"w")
132
+
133
+ #Write data into file
134
+ template.puts <<~DOC.gsub(/\t/, '')
135
+ ---
136
+ name: #{card.name}
137
+ ---
138
+ DOC
139
+ template.puts "#{card.desc}"
140
+ template.close
141
+
142
+ # Create Hard coded Blocks (like carousel's)
143
+ elsif card.list.name == init_config.blocks then
144
+
145
+ #get blocks dir name from file manager config
146
+ dir_name = f_manager.blocks_dir
147
+ f_name = card.name.sanitize_as_page_name
148
+ block_name = "#{f_name}.md"
149
+
150
+ # Get attachments from widget
151
+ tmp = Hash.new
152
+ attachment_url = ""
153
+ # hash_test = [] ("pos" still not implemented in trello API)
154
+ unless card.attachments.nil? then
155
+ card.attachments.each do |attachment|
156
+ #Get url and pos (position) into temp Hash
157
+ k = attachment.pos
158
+ v = attachment.url
159
+ tmp[k] = v
160
+ end
161
+ # Sort hash and get url's
162
+ sorted_hash = tmp.sort.reverse.to_h
163
+ attachment_url = sorted_hash.map { |k, v| "\"#{[v].flatten.join(',')}\"" }.join(', ')
164
+
165
+ puts "Attachment: #{attachment_url}" if attachment_url != ""
166
+ end
167
+
168
+ template = File.open(File.join(Dir.pwd, dir_name, block_name),"w")
169
+ #Write data into file
170
+ template.puts <<~DOC.gsub(/\t/, '')
171
+ ---
172
+ name: #{card.name}
173
+ attachments: [ #{attachment_url} ]
174
+ ---
175
+ DOC
176
+ # template.puts "#{card.desc}" Interpret content ?! TO DO
177
+ template.close
178
+
179
+ # Create Posts from posts List (multiple list names allowed)
180
+ elsif init_config.posts.include?(card.list.name) then
181
+ #get dir with list name
182
+ dir_name = f_manager.posts_dir
183
+ #create file name based on date and card name
184
+ file_name = "#{card.created_at.strftime("%Y-%m-%d")}-#{card.name.sanitize_as_post_name}.md"
185
+
186
+ label_name = ""
187
+
188
+ unless card.labels.nil? then
189
+ card.labels.each do |label|
190
+ label_name = label_name + " " + label.name
191
+ end
192
+ end
193
+
194
+ # Gget cover image
195
+ cover_id = card.cover_image_id
196
+ cover_image_url = ""
197
+ unless card.attachments.nil? then
198
+ card.attachments.each do |attachment|
199
+ if attachment.id == cover_id
200
+ cover_image_url = attachment.url
201
+ end
202
+ end
203
+
204
+ puts "Post cover image: #{cover_image_url} " if cover_image_url != ""
205
+
206
+ end
207
+
208
+ template = File.open(File.join(Dir.pwd, dir_name, file_name),"w")
209
+ #Write data into file
210
+ template.puts <<~DOC.gsub(/\t/, '')
211
+ ---
212
+ layout: post
213
+ header: "#{cover_image_url}"
214
+ title: #{card.name}
215
+ date: #{card.created_at}
216
+ categories: #{card.list.name.sanitize_as_post_name}
217
+ tags: #{label_name}
218
+ ---
219
+ DOC
220
+ template.puts "#{card.desc}"
221
+ template.close
222
+ end
223
+ end
224
+ return true
225
+ end
226
+ end
@@ -0,0 +1,3 @@
1
+ module Trekyll
2
+ VERSION = "0.1.1".freeze
3
+ end
data/lib/trekyll.rb ADDED
@@ -0,0 +1,43 @@
1
+ require "trekyll/version"
2
+ require "trekyll/trello_get"
3
+ require "trekyll/initializator"
4
+
5
+ module Trekyll
6
+ # CLI argument interpretter
7
+ def self.command_interpretter(arg)
8
+ case arg
9
+ when "-v"
10
+ puts "trekyll " + Trekyll::VERSION
11
+ when "init"
12
+ #initialize coppy _init.yml and _config.yml
13
+ fc = Trekyll::TemplateFilesInit.new
14
+ fc.templates_init()
15
+ when "get"
16
+ # start get trello data
17
+ if Trekyll.start_trekyll()
18
+ # when get is complete run jekyll build
19
+ puts "Now Building Website!"
20
+ cmd ="jekyll build"
21
+ system(cmd)
22
+ end
23
+ when "clear"
24
+ # Clear all data files
25
+ when "-h","--help", nil
26
+ # defoult info
27
+ puts "trekyll " + Trekyll::VERSION + " -- Jekyll plugin to use Trello board as CMS backend"
28
+ puts "Usage:"
29
+ puts " trekyll <subcommand>"
30
+ puts ""
31
+ puts "Subcommands:"
32
+ puts " --help"
33
+ puts " -h Print this help message"
34
+ puts " init Initialize Trekyll configuration (creates _init.yml and default Jekyll _config.yml)"
35
+ puts " get Get data from Trello board and modify it for Jekyll usage"
36
+ else
37
+ puts "Trekyll command not recognized"
38
+ puts "use: -h or --help to see available commands"
39
+ end
40
+
41
+ end
42
+
43
+ end
data/trekyll.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trekyll/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trekyll"
8
+ spec.version = Trekyll::VERSION
9
+ spec.authors = ["Canic Interactive"]
10
+ spec.email = ["nenad.mucic@canicinteractive.com"]
11
+
12
+ spec.summary = %q{Trello to Jekyll CMS}
13
+ spec.description = %q{Jekyll plugin for grabbing Trello content in CMS manner}
14
+ spec.homepage = "https://rubygems.org/gems/trekyll"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
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"
36
+ spec.add_runtime_dependency "indentation", "~> 0.1.1"
37
+
38
+ # spec.add_development_dependency "bundler", "~> 1.14"
39
+ # spec.add_development_dependency "rake", "~> 10.0"
40
+ # spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trekyll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Canic Interactive
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: trelloapi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: indentation
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.1
41
+ description: Jekyll plugin for grabbing Trello content in CMS manner
42
+ email:
43
+ - nenad.mucic@canicinteractive.com
44
+ executables:
45
+ - trekyll
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".DS_Store"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".travis.yml"
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - config_templates/_config.yml
60
+ - config_templates/_init.yml
61
+ - exe/trekyll
62
+ - lib/.DS_Store
63
+ - lib/trekyll.rb
64
+ - lib/trekyll/configurator.rb
65
+ - lib/trekyll/core_ext/string.rb
66
+ - lib/trekyll/filemanager.rb
67
+ - lib/trekyll/initializator.rb
68
+ - lib/trekyll/navigation_manager.rb
69
+ - lib/trekyll/trello_get.rb
70
+ - lib/trekyll/version.rb
71
+ - trekyll.gemspec
72
+ homepage: https://rubygems.org/gems/trekyll
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.8
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Trello to Jekyll CMS
96
+ test_files: []