jekyll_trello 0.1.6

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/jekyll_trello +13 -0
  3. data/lib/jekyll_trello.rb +222 -0
  4. metadata +53 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6eaba83ac9482161f7c7e4f29a0750d621aaa50bde814fc659fc4eb589a422a
4
+ data.tar.gz: e0f7cf5a7587013829fbec4675980c99068a2d26d0cdeea76ebe818ddbdeb7e8
5
+ SHA512:
6
+ metadata.gz: 824bf8dab94039240b71b5ba6c0405ebea73cc4aaf158bf92bdfb09e0b9bcfa024b1df561657a397594329547b3153b31d77dfb0a472f9a3b2dd6fcab8d343a3
7
+ data.tar.gz: 5dbb7ceb4d991cd0605de6d48c8619b8c77bfec60aeb390ccf8900b612a7dbaf72d36190dd6de7d188798091e35f945e7a50dd8d70e75a4b94bfea10f0d7f48f
data/bin/jekyll_trello ADDED
@@ -0,0 +1,13 @@
1
+ require "jekyll_trello"
2
+
3
+ unless ARGV.empty?
4
+ idList= ARGV.first.gsub(/^--/,'')
5
+ puts "idList passed: #{idList}"
6
+ JekyllTrello.creator(idList)
7
+ exit
8
+ else
9
+ puts "You must pass your ldList as flags like this"
10
+ puts "jekyll_trello --6759348bb364c0a0ad05e54c"
11
+ end
12
+
13
+
@@ -0,0 +1,222 @@
1
+ class JekyllTrello
2
+ def self.creator(idList)
3
+ bundle_install
4
+ github
5
+ Dir.mkdir("_plugins") unless Dir.exist?("_plugins")
6
+ content = <<~RUBY
7
+ require 'dotenv/load'
8
+ require 'trello'
9
+ # require 'pry'
10
+ module Jekyll
11
+ class ContentCreatorGenerator < Generator
12
+ safe true
13
+ ACCEPTED_COLOR = "green"
14
+
15
+ def setup
16
+ @trello_api_key = ENV['TRELLO_API_KEY']
17
+ @trello_token = ENV['TRELLO_TOKEN']
18
+
19
+ Trello.configure do |config|
20
+ config.developer_public_key = @trello_api_key
21
+ config.member_token = @trello_token
22
+ end
23
+ end
24
+
25
+ def generate(site)
26
+ setup
27
+ existing_posts = Dir.glob("./_posts/*").map { |f| File.basename(f) }
28
+
29
+ cards = Trello::List.find("#{idList}").cards
30
+ cards.each do |card|
31
+ labels = card.labels.map { |label| label.color }
32
+ next unless labels.include?(ACCEPTED_COLOR)
33
+ due_on = card.due&.to_date.to_s
34
+ slug = card.name.split.join("-").downcase
35
+ created_on = DateTime.strptime(card.id[0..7].to_i(16).to_s, '%s').to_date.to_s
36
+ article_date = due_on.empty? ? created_on : due_on
37
+ content = """---
38
+ layout: post
39
+ title: \#{card.name}
40
+ date: \#{article_date}
41
+ permalink: \#{slug}
42
+ ---
43
+
44
+ \#{card.desc}
45
+ """
46
+ file_path = "./_posts/\#{article_date}-\#{slug}.md"
47
+ if !File.exist?(file_path) || File.read(file_path) != content
48
+ File.open(file_path, "w+") { |f| f.write(content) }
49
+ end
50
+ existing_posts.delete("\#{article_date}-\#{slug}.md")
51
+ end
52
+
53
+ existing_posts.each do |stale_post|
54
+ file_path = "./_posts/\#{stale_post}"
55
+ File.delete(file_path) if File.exist?(file_path)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ RUBY
61
+
62
+ file_path = "_plugins/creater.rb"
63
+ File.write(file_path, content)
64
+ puts "File '#{file_path}' has been created successfully!"
65
+ end
66
+
67
+ def self.github
68
+ ruby_version
69
+ scripts
70
+ env_gitignore
71
+ content= <<~'RUBY'
72
+ name: Build blogs from Trello Card
73
+
74
+ on:
75
+ push:
76
+ branches:
77
+ - gh-pages
78
+ schedule:
79
+ - cron: '0 0 * * *'
80
+ workflow_dispatch:
81
+
82
+ jobs:
83
+ build-and-deploy:
84
+ name: Build and commit on same branch
85
+ runs-on: ubuntu-latest
86
+ steps:
87
+ - name: Checkout source code
88
+ uses: actions/checkout@v2
89
+
90
+ - name: create .env file
91
+ run: echo "${{ secrets.DOT_ENV }}" > .env
92
+
93
+ - name: Setup ruby
94
+ run: echo "::set-output name=RUBY_VERSION::$(cat .ruby-version)"
95
+ id: rbenv
96
+
97
+ - name: Use Ruby ${{ steps.rbenv.outputs.RUBY_VERSION }}
98
+ uses: ruby/setup-ruby@v1
99
+
100
+ - name: Use cache gems
101
+ uses: actions/cache@v1
102
+ with:
103
+ path: vendor/bundle
104
+ key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
105
+ restore-keys: |
106
+ ${{ runner.os }}-gem-
107
+
108
+ - name: bundle install
109
+ run: |
110
+ gem install bundler -v 2.4.22
111
+ bundle install --jobs 4 --retry 3 --path vendor/bundle
112
+
113
+ - name: rm posts
114
+ run: |
115
+ cp ./scripts/rmposts.sh _posts/rmposts.sh
116
+ chmod +x _posts/rmposts.sh
117
+ cd _posts
118
+ sh rmposts.sh
119
+ rm rmposts.sh
120
+ cd ..
121
+ - name: Build posts
122
+ run: |
123
+ bundle exec jekyll build
124
+
125
+ - uses: EndBug/add-and-commit@v7
126
+ with:
127
+ add: '*.md'
128
+ author_name: Habi Pyatha
129
+ branch: gh-pages
130
+ message: 'auto commit'
131
+ RUBY
132
+ Dir.mkdir(".github") unless Dir.exist?(".github")
133
+ Dir.mkdir(".github/workflows") unless Dir.exist?(".github/workflows")
134
+ file_path = ".github/workflows/build-block.yml"
135
+ File.write(file_path, content)
136
+ puts "File '#{file_path}' has been created successfully!"
137
+
138
+ end
139
+
140
+ def self.ruby_version
141
+ file_path = ".ruby-version"
142
+ File.write(file_path, "3.3.4")
143
+ puts "File '#{file_path}' has been created successfully!"
144
+ end
145
+
146
+ def self.scripts
147
+ content= <<~'RUBY'
148
+ counts= `ls -1 *.md 2>/dev/null | wc-1`
149
+ if [ $count != 0]
150
+ then
151
+ echo true
152
+ echo "Removing all md files"
153
+ rm *.md
154
+ fi
155
+ RUBY
156
+ Dir.mkdir("scripts") unless Dir.exist?("scripts")
157
+ file_path = "scripts/rmposts.sh"
158
+ File.write(file_path, content)
159
+ puts "File '#{file_path}' has been created successfully!"
160
+
161
+ end
162
+
163
+ def self.bundle_install
164
+ gemfile_path = "Gemfile"
165
+
166
+ unless File.exist?(gemfile_path)
167
+ gemfile_content=<<~GEMFILE
168
+ source 'https://rubygems.org'
169
+
170
+ gem 'ruby-trello'
171
+ gem 'dotenv'
172
+ GEMFILE
173
+ File.write(gemfile_path, gemfile_content)
174
+ else
175
+ gemfile_content = File.read(gemfile_path)
176
+
177
+ unless gemfile_content.include?("dotenv")
178
+ gemfile_content +="\ngem 'dotenv' \n"
179
+ end
180
+ unless gemfile_content.include?("ruby-trello")
181
+ gemfile_content +="\ngem 'ruby-trello' \n"
182
+ end
183
+
184
+ File.write(gemfile_path,gemfile_content)
185
+ puts "Gems 'ruby-trello' and 'dotenv' added to Gemfile."
186
+
187
+ end
188
+ system("bundle install")
189
+ puts "Gems installed successfully!"
190
+ end
191
+
192
+ def self.env_gitignore
193
+ gitignore_path=".gitignore"
194
+
195
+ if File.exist?(gitignore_path)
196
+ gitignore_content = File.read(gitignore_path)
197
+
198
+ unless gitignore_content.include?(".env")
199
+ File.open(gitignore_path, "a") do |file|
200
+ file.puts(".env")
201
+ end
202
+ puts ".env has been added to .gitignore"
203
+ else
204
+ puts ".env is already in .gitignore"
205
+ end
206
+ else
207
+ puts "No .gitignore file found. Please create one first."
208
+ end
209
+
210
+ end
211
+
212
+
213
+
214
+ end
215
+
216
+ # idList = "6759348bb364c0a0ad05e54c"
217
+ # JekyllTrello.creator(idList)
218
+ # JekyllTrello.github
219
+ # JekyllTrello.ruby_version
220
+ # JekyllTrello.scripts
221
+ # JekyllTrello.bundle_install
222
+ # JekyllTrello.env_gitignore
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_trello
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Habi Coder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Extract the trello cards details and show it in your trello website also
14
+ automatically runs daily if hosted on github
15
+ email: unionhab@gmail.com
16
+ executables:
17
+ - jekyll_trello
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/jekyll_trello
22
+ - lib/jekyll_trello.rb
23
+ homepage: https://github.com/Habi-Pyatha
24
+ licenses: []
25
+ metadata:
26
+ source_code_uri: https://github.com/Habi-Pyatha
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.5.20
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: This is will help you setup your jekyll website in github and take data from
46
+ trello automatically once a day if label is set to green. .....put your github repo
47
+ name inside baseurl:'/your_repo_name' in _config.yml......put secret in secrets
48
+ and vairable in github like this name=DOT_ENV........Secret='TRELLO_API_KEY=66afksdlf994d36591bd41a9f82c4b927
49
+ TRELLO_TOKEN=ATTA63d96531e13dc90ca874c17efasdfdsfbd9fb7700e4699816FCFEBA51 ' and
50
+ you have to set.........workflow permissions to read and write permission.........inside
51
+ action>general......you can use this gem like this...'jekyll_terllo --897lfkdjsjfklsdj'........idList
52
+ of your card of trello........
53
+ test_files: []