sweetie 1.0.1 → 2.0.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 +7 -0
- data/.circleci/config.yml +30 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +16 -0
- data/Gemfile +3 -3
- data/README.md +264 -44
- data/Rakefile +3 -2
- data/lib/sweetie/bitbucket.rb +27 -204
- data/lib/sweetie/bitbucket_stati_helper.rb +247 -0
- data/lib/sweetie/conversion.rb +94 -67
- data/lib/sweetie/helper.rb +60 -55
- data/lib/sweetie/version.rb +2 -1
- data/lib/sweetie.rb +2 -2
- data/spec/fixtures/bitbucket/expected_repositories.txt +1 -0
- data/spec/fixtures/bitbucket/repositories.json +1 -0
- data/spec/fixtures/jekyll/_config.yml +4 -0
- data/spec/fixtures/jekyll/_config_repositories.yml +7 -0
- data/spec/fixtures/jekyll/_expected_config.yml +4 -0
- data/spec/{source → fixtures/jekyll}/site/404.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/about.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/archiv.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/atom.xml +0 -0
- data/spec/{source → fixtures/jekyll}/site/colophon.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/contact.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/follow.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/2_avatars.gif +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/favicon.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_normal.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_small.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/closebox.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-fill.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-l.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-r.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow1.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow2.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow3.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow4.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow5.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow6.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow7.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow8.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-1.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-10.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-11.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-12.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-2.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-3.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-4.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-5.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-6.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-7.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-8.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-9.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/rails3.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/index.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/robots.txt +0 -0
- data/spec/{source → fixtures/jekyll}/site/sitemap.xml +0 -0
- data/spec/{source → fixtures/jekyll}/site/why-i-use-jekyll-for-blogging.html +0 -0
- data/spec/fixtures/middleman/build/2012-01-meetup/index.html +238 -0
- data/spec/fixtures/middleman/build/2012-03-meetup/index.html +217 -0
- data/spec/fixtures/middleman/build/2012-05-meetup/index.html +214 -0
- data/spec/fixtures/middleman/build/2012-07-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/2012-08-workshop/index.html +228 -0
- data/spec/fixtures/middleman/build/2012-09-meetup/index.html +231 -0
- data/spec/fixtures/middleman/build/2012-10-workshop/index.html +227 -0
- data/spec/fixtures/middleman/build/2012-11-meetup/index.html +229 -0
- data/spec/fixtures/middleman/build/2012-unusual-december-meetup/index.html +186 -0
- data/spec/fixtures/middleman/build/2013-01-meetup/index.html +226 -0
- data/spec/fixtures/middleman/build/404/index.html +157 -0
- data/spec/fixtures/middleman/build/CNAME +1 -0
- data/spec/fixtures/middleman/build/april-2014-meetup/index.html +221 -0
- data/spec/fixtures/middleman/build/april-2015-meetup/index.html +204 -0
- data/spec/fixtures/middleman/build/april-2017-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-192x192.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-36x36.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-48x48.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-72x72.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-96x96.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-114x114.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-120x120.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-152x152.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-180x180.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-57x57.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-60x60.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-72x72.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-76x76.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-precomposed.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/browserconfig.xml +12 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-16x16.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-32x32.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-96x96.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon.ico +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/manifest.json +41 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-150x150.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-310x150.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-310x310.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-70x70.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/safari-pinned-tab.svg +450 -0
- data/spec/fixtures/middleman/build/assets/images/launch_co_logo.png +0 -0
- data/spec/fixtures/middleman/build/assets/images/vimfest.png +0 -0
- data/spec/fixtures/middleman/build/assets/javascripts/application.js +12 -0
- data/spec/fixtures/middleman/build/assets/javascripts/jquery.utils.js +12 -0
- data/spec/fixtures/middleman/build/assets/javascripts/lib/validate.js +1 -0
- data/spec/fixtures/middleman/build/assets/stylesheets/application.css +5 -0
- data/spec/fixtures/middleman/build/assets/stylesheets/vendor/bootstrap.css +5 -0
- data/spec/fixtures/middleman/build/august-2013-meetup/index.html +208 -0
- data/spec/fixtures/middleman/build/blog/index.html +500 -0
- data/spec/fixtures/middleman/build/book-club-about-the-viml-primer/index.html +182 -0
- data/spec/fixtures/middleman/build/contact/index.html +155 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2013-09_ctags/index.html +98 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2013-09_vimprofiling/index.html +157 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2014-01_vim_writing/index.html +70 -0
- data/spec/fixtures/middleman/build/december-2015-meetup/index.html +199 -0
- data/spec/fixtures/middleman/build/december-2016-meetup/index.html +224 -0
- data/spec/fixtures/middleman/build/february-2013-vim-beer-lin/index.html +190 -0
- data/spec/fixtures/middleman/build/february-2015-meetup/index.html +233 -0
- data/spec/fixtures/middleman/build/february-2016-meetup/index.html +271 -0
- data/spec/fixtures/middleman/build/feed.xml +2106 -0
- data/spec/fixtures/middleman/build/fonts/FontAwesome.otf +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.eot +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.svg +655 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.ttf +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff2 +0 -0
- data/spec/fixtures/middleman/build/humans.txt +12 -0
- data/spec/fixtures/middleman/build/imprint/index.html +177 -0
- data/spec/fixtures/middleman/build/index.html +157 -0
- data/spec/fixtures/middleman/build/january-2014-meetup/index.html +257 -0
- data/spec/fixtures/middleman/build/january-2015-meetup/index.html +243 -0
- data/spec/fixtures/middleman/build/january-2016-meetup/index.html +202 -0
- data/spec/fixtures/middleman/build/january-2017-meetup/index.html +228 -0
- data/spec/fixtures/middleman/build/july-2015-meetup/index.html +207 -0
- data/spec/fixtures/middleman/build/june-2016-meetup/index.html +260 -0
- data/spec/fixtures/middleman/build/march-2-2017-meetup/index.html +201 -0
- data/spec/fixtures/middleman/build/march-2014-meetup/index.html +219 -0
- data/spec/fixtures/middleman/build/march-2016-meetup/index.html +221 -0
- data/spec/fixtures/middleman/build/march-2017-meetup/index.html +222 -0
- data/spec/fixtures/middleman/build/may-2013-meetup/index.html +234 -0
- data/spec/fixtures/middleman/build/may-2014-meetup/index.html +198 -0
- data/spec/fixtures/middleman/build/may-2015-meetup/index.html +202 -0
- data/spec/fixtures/middleman/build/may-2016-meetup/index.html +245 -0
- data/spec/fixtures/middleman/build/newsletter/index.html +171 -0
- data/spec/fixtures/middleman/build/november-2013-meetup/index.html +199 -0
- data/spec/fixtures/middleman/build/november-2015-meetup/index.html +402 -0
- data/spec/fixtures/middleman/build/november-2016-meetup/index.html +224 -0
- data/spec/fixtures/middleman/build/october-2013-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/october-2014-meetup/index.html +196 -0
- data/spec/fixtures/middleman/build/october-2016-meetup/index.html +222 -0
- data/spec/fixtures/middleman/build/robots.txt +6 -0
- data/spec/fixtures/middleman/build/september-2013-meetup/index.html +225 -0
- data/spec/fixtures/middleman/build/september-2014-meetup/index.html +211 -0
- data/spec/fixtures/middleman/build/sitemap.xml +297 -0
- data/spec/fixtures/middleman/build/vimfest-october-2015/index.html +303 -0
- data/spec/fixtures/middleman/config.rb +4 -0
- data/spec/fixtures/middleman/config_repositories.rb +7 -0
- data/spec/fixtures/middleman/expected_config.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/sweetie_bitbucket_spec.rb +26 -53
- data/spec/sweetie_bitbucket_stati_helper_spec.rb +124 -0
- data/spec/sweetie_conversion_spec.rb +104 -18
- data/spec/sweetie_helper_spec.rb +140 -0
- data/sweetie.gemspec +13 -17
- metadata +185 -86
- data/.travis.yml +0 -5
- data/spec/source/_config.yml +0 -18
- data/spec/source/bitbucket/user_repositories.json +0 -161
- data/spec/source/bitbucket/user_repositories_expectation.txt +0 -1
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9c72e80cb6e5b88d94022d6e9dc791ebb2d5534c7f8ffd1ef66ffd8ec0286cea
|
|
4
|
+
data.tar.gz: 2ff9a301c9c745313a7c9c09f2f7349286750fd628d960d4d7f4cbacc90bb164
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: aa682817dc4378b914556e08cde7c491695e76168681ed2692146376dd0cfa6656cf2aab5cc50d404af40f595c64d0ce5278fd179e66136437bfaa334004a747
|
|
7
|
+
data.tar.gz: 142557f220374c97cfb200ad706f8288c4d4d2fd5be287d202683c8ec0e43314311b168e6f52bf4b1eb0421088303765924bed4f72cfc7560163a4c7d814787a
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@0.1.2
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
parameters:
|
|
8
|
+
ruby-version:
|
|
9
|
+
type: string
|
|
10
|
+
docker:
|
|
11
|
+
- image: circleci/ruby:<< parameters.ruby-version >>
|
|
12
|
+
executor: ruby/default
|
|
13
|
+
steps:
|
|
14
|
+
- checkout
|
|
15
|
+
- run:
|
|
16
|
+
name: Which bundler?
|
|
17
|
+
command: gem install bundler:2.2.26
|
|
18
|
+
- ruby/bundle-install
|
|
19
|
+
- run:
|
|
20
|
+
name: Run rspec tests
|
|
21
|
+
command: bundle exec rspec
|
|
22
|
+
workflows:
|
|
23
|
+
build_and_test:
|
|
24
|
+
jobs:
|
|
25
|
+
- build:
|
|
26
|
+
matrix:
|
|
27
|
+
parameters:
|
|
28
|
+
# https://github.com/CircleCI-Public/cimg-ruby
|
|
29
|
+
# only supports the last three ruby versions
|
|
30
|
+
ruby-version: ["2.6.0", "2.6.5", "2.7.4", "3.0.2"]
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Documentation:
|
|
2
|
+
Enabled: false
|
|
3
|
+
|
|
4
|
+
Metrics/LineLength:
|
|
5
|
+
Max: 150
|
|
6
|
+
Metrics/BlockLength:
|
|
7
|
+
Max: 150
|
|
8
|
+
|
|
9
|
+
Layout/TrailingBlankLines:
|
|
10
|
+
EnforcedStyle: final_blank_line
|
|
11
|
+
|
|
12
|
+
Style/RedundantSelf:
|
|
13
|
+
Enabled: false
|
|
14
|
+
Style/HashSyntax:
|
|
15
|
+
EnforcedStyle: no_mixed_keys
|
|
16
|
+
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,37 +1,83 @@
|
|
|
1
|
-
Sweetie is a plugin for [jekyll](
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Sweetie is a plugin for to get statistics for [jekyll](http://jekyllrb.com/ "jekyll") and
|
|
2
|
+
[middleman](https://middlemanapp.com/ "middleman") projects. The statistics includes the unique number of all links,
|
|
3
|
+
images, pages, and the last build time of the given project. You can specify the location the generated files
|
|
4
|
+
(normally `_site` for jekyll and `build` for middleman apps) and of the `config` file where the changes
|
|
5
|
+
will be written.
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
It can also grab the last changes of your bitbucket repositories. You can then use the information on various places in
|
|
9
|
+
your project
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
[](http://badge.fury.io/rb/sweetie)
|
|
12
|
+
[](https://app.circleci.com/pipelines/github/wikimatze/sweetie)
|
|
9
13
|
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Toc
|
|
16
|
+
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage create stati](#usage-create-stati)
|
|
19
|
+
- [Jekyll](#jekyll "Jekyll projects")
|
|
20
|
+
- [Configuration variables for Jekyll](#configuration-variables-for-jekyll "Configuration variables for Jekyll")
|
|
21
|
+
- [Middleman](#middleman "Middleman projects")
|
|
22
|
+
- [Configuration variables for Middleman](#configuration-variables-for-middleman "Configuration variables for Middleman")
|
|
23
|
+
- [Usage bitbucket repositories](#usage-bitbucket-repositories "Usage bitbucket repositories")
|
|
24
|
+
- [Middleman](#middleman-1 "Middleman")
|
|
25
|
+
- [Jekyll](#jekyll-1 "Jekyll")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
$ gem install sweetie
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Usage create stati
|
|
36
|
+
|
|
37
|
+
### Jekyll
|
|
12
38
|
|
|
13
39
|
The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
|
|
14
40
|
|
|
15
41
|
Before you build your page, you can run a rake task to update the status information of a page:
|
|
16
42
|
|
|
17
|
-
desc 'write stats in the _config.yml'
|
|
18
|
-
task :create_stati do
|
|
19
|
-
Sweetie::Conversion.conversion
|
|
20
|
-
end
|
|
21
43
|
|
|
22
|
-
|
|
44
|
+
```ruby
|
|
45
|
+
require 'sweetie'
|
|
46
|
+
|
|
47
|
+
desc 'write stats in the _config.yml file'
|
|
48
|
+
task :create_stati do
|
|
49
|
+
sweetie = Sweetie::Conversion.new('./site', './_config.yml')
|
|
50
|
+
sweetie.create_stati
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Make sure that the following fields are set in your `_config.yml`:
|
|
56
|
+
|
|
23
57
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
58
|
+
```yml
|
|
59
|
+
build:
|
|
60
|
+
htmlpages:
|
|
61
|
+
images:
|
|
62
|
+
links:
|
|
63
|
+
```
|
|
28
64
|
|
|
29
65
|
|
|
30
|
-
|
|
66
|
+
After running the script, the changes in `_config.yml` will look like:
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
build: 6-18-2017
|
|
71
|
+
htmlpages: 600
|
|
72
|
+
images: 20
|
|
73
|
+
links: 271
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Configuration variables for Jekyll
|
|
78
|
+
|
|
79
|
+
You can use the `build`, `htmlpages`, `images`, and `links` variables defined in your `_config.yml` file everywhere in your page with the liquid snippet for example:
|
|
31
80
|
|
|
32
|
-
Call the class method `Sweetie::Bitbucket.bitbucket("yourname")` and it will automatically append
|
|
33
|
-
the `build`, `htmlpages`, `images`, and `links` in your `_config.yml` file. You can then use them
|
|
34
|
-
everywhere in your page with the liquid snippet for example:
|
|
35
81
|
|
|
36
82
|
- `{{ site.build }}`
|
|
37
83
|
- `{{ site.htmlpages }}`
|
|
@@ -39,45 +85,219 @@ everywhere in your page with the liquid snippet for example:
|
|
|
39
85
|
- `{{ site.links }}`
|
|
40
86
|
|
|
41
87
|
|
|
42
|
-
|
|
88
|
+
If you also make use of [Usage for Bitbucket repositories](#usage-for-bitbucket-repositories "Usage for Bitbucket repositories") you can also use the last update value for your repositories:
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<section class="lastupdate">
|
|
93
|
+
Last update {{ site.git }}
|
|
94
|
+
</section>
|
|
95
|
+
...
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
<section class="lastupdate">
|
|
99
|
+
Last update {{ site.pmwiki-twitter-recipe }}
|
|
100
|
+
</section>
|
|
101
|
+
...
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
will result the following html:
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<h3 id="git">Git</h3>
|
|
110
|
+
|
|
111
|
+
<section class="lastupdate">
|
|
112
|
+
Last update 2011-10-16
|
|
113
|
+
</section>
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<h3 id="twitter">Twitter</h3>
|
|
117
|
+
|
|
118
|
+
<section class="lastupdate">
|
|
119
|
+
Last update 2011-10-16
|
|
120
|
+
</section>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
### Middleman
|
|
126
|
+
|
|
127
|
+
The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
|
|
128
|
+
|
|
129
|
+
Before you build your page, you can run a rake task to update the status information of a page:
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
require 'sweetie'
|
|
134
|
+
|
|
135
|
+
desc 'write stats in the config.rb file'
|
|
136
|
+
task :create_stati do
|
|
137
|
+
sweetie = Sweetie::Conversion.new('./build', './config.rb')
|
|
138
|
+
sweetie.create_stati
|
|
139
|
+
end
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
Make sure that the following fields are set in your `config.rb`:
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
```yml
|
|
147
|
+
set :build,
|
|
148
|
+
set :images,
|
|
149
|
+
set :htmlpages,
|
|
150
|
+
set :links,
|
|
151
|
+
```
|
|
43
152
|
|
|
44
|
-
Call the class method `Sweetie::Bitbucket.bitbucket("yourname")` and it will automatically append
|
|
45
|
-
the repository name an the last change of the repository in your `_config.yml`. Here is an example:
|
|
46
153
|
|
|
47
|
-
|
|
48
|
-
pmwiki-twitter-recipe: 2011-10-29
|
|
154
|
+
After running the script, the changes in `config.rb` will look like for example:
|
|
49
155
|
|
|
50
|
-
You can then use this variables in the view of your jekyll project with the liquid template. For
|
|
51
|
-
example:
|
|
52
156
|
|
|
53
|
-
|
|
157
|
+
```ruby
|
|
158
|
+
set :build, 6-18-2017
|
|
159
|
+
set :images, 75
|
|
160
|
+
set :htmlpages, 111
|
|
161
|
+
set :links, 694
|
|
162
|
+
```
|
|
54
163
|
|
|
55
|
-
<section class="lastupdate">
|
|
56
|
-
Last update {{ site.git }}
|
|
57
|
-
</section>
|
|
58
|
-
...
|
|
59
164
|
|
|
165
|
+
### Configuration variables for Middleman
|
|
60
166
|
|
|
61
|
-
|
|
167
|
+
You can use the `build`, `htmlpages`, `images`, and `links` variables defined in your `_config.yml` file everywhere in your page with the erb snippet for example:
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
- `<%= config[:build] %>
|
|
171
|
+
- `<%= config[:htmlpages] %>
|
|
172
|
+
- `<%= config[:images] %>
|
|
173
|
+
- `<%= config[:links] %>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
If you also make use of [Usage for Bitbucket repositories](#usage-for-bitbucket-repositories "Usage for Bitbucket repositories") you can also use the last update value for your repositories:
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
|
|
181
|
+
<section class="lastupdate">
|
|
182
|
+
Last update <%= config[:git] %>
|
|
183
|
+
</section>
|
|
184
|
+
...
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<section class="lastupdate">
|
|
188
|
+
Last update <%= config[:pmwiki_twitter_recipe %>
|
|
189
|
+
</section>
|
|
190
|
+
...
|
|
191
|
+
```
|
|
62
192
|
|
|
63
|
-
<section class="lastupdate">
|
|
64
|
-
Last update {{ site.pmwiki-twitter-recipe }}
|
|
65
|
-
</section>
|
|
66
|
-
...
|
|
67
193
|
|
|
68
194
|
will result the following html:
|
|
69
195
|
|
|
70
196
|
|
|
71
|
-
|
|
197
|
+
```html
|
|
198
|
+
<h3 id="git">Git</h3>
|
|
199
|
+
|
|
200
|
+
<section class="lastupdate">
|
|
201
|
+
Last update 2011-10-16
|
|
202
|
+
</section>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<h3 id="twitter">Twitter</h3>
|
|
206
|
+
|
|
207
|
+
<section class="lastupdate">
|
|
208
|
+
Last update 2011-10-16
|
|
209
|
+
</section>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
## Usage Bitbucket repositories
|
|
214
|
+
|
|
215
|
+
### Middleman
|
|
216
|
+
|
|
217
|
+
The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
|
|
218
|
+
|
|
219
|
+
Before you build your page, you can run a rake task to update the status of the repositories for the given `config-file` and `username`:
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
```ruby
|
|
223
|
+
require 'sweetie'
|
|
224
|
+
|
|
225
|
+
desc 'write repositories stats in the config.rb file'
|
|
226
|
+
task :create_bitbucket do
|
|
227
|
+
stati_helper = Sweetie::BitbucketStatiHelper.new('./config.rb', 'wikimatze')
|
|
228
|
+
bitbucket = Sweetie::Bitbucket.new(stati_helper)
|
|
229
|
+
bitbucket.update_stati
|
|
230
|
+
end
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Please note that you have to change `wikimatze` to your bitbucket user name
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
```ruby
|
|
237
|
+
set :pmwiki_dropcaps_recipe,
|
|
238
|
+
set :pmwiki_syntaxlove_recipe,
|
|
239
|
+
set :pmwiki_twitter_recipe,
|
|
240
|
+
set :pmwiki_linkicons_recipe,
|
|
241
|
+
set :pmwiki_headlineimage_recipe,
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
After running the script, the names in `config.rb` above will be changed to:
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
```ruby
|
|
249
|
+
set :pmwiki_dropcaps_recipe, 2017-02-24
|
|
250
|
+
set :pmwiki_syntaxlove_recipe, 2017-02-26
|
|
251
|
+
set :pmwiki_twitter_recipe, 2017-02-26
|
|
252
|
+
set :pmwiki_linkicons_recipe, 2017-02-26
|
|
253
|
+
set :pmwiki_headlineimage_recipe, 2017-02-25
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
### Jekyll
|
|
258
|
+
|
|
259
|
+
The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
|
|
260
|
+
|
|
261
|
+
Before you build your page, you can run a rake task to update the status of the repositories for the given `config-file` and `username`:
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
```ruby
|
|
265
|
+
require 'sweetie'
|
|
266
|
+
|
|
267
|
+
desc 'write repositories stats in the _config.yml file'
|
|
268
|
+
desc 'write stats in the _config.yml'
|
|
269
|
+
task :create_bitbucket do
|
|
270
|
+
stati_helper = Sweetie::BitbucketStatiHelper.new('./_config.yml', 'wikimatze')
|
|
271
|
+
bitbucket = Sweetie::Bitbucket.new(stati_helper)
|
|
272
|
+
bitbucket.update_stati
|
|
273
|
+
end
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Please note that you have to change `wikimatze` to your bitbucket user name
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
```ruby
|
|
280
|
+
set :pmwiki_dropcaps_recipe,
|
|
281
|
+
set :pmwiki_syntaxlove_recipe,
|
|
282
|
+
set :pmwiki_twitter_recipe,
|
|
283
|
+
set :pmwiki_linkicons_recipe,
|
|
284
|
+
set :pmwiki_headlineimage_recipe,
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
After running the script, the names in `config.rb` above will be changed to:
|
|
72
289
|
|
|
73
|
-
<section class="lastupdate">
|
|
74
|
-
Last update 2011-10-16
|
|
75
|
-
</section>
|
|
76
290
|
|
|
291
|
+
```ruby
|
|
292
|
+
set :pmwiki_dropcaps_recipe, 2017-02-24
|
|
293
|
+
set :pmwiki_syntaxlove_recipe, 2017-02-26
|
|
294
|
+
set :pmwiki_twitter_recipe, 2017-02-26
|
|
295
|
+
set :pmwiki_linkicons_recipe, 2017-02-26
|
|
296
|
+
set :pmwiki_headlineimage_recipe, 2017-02-25
|
|
297
|
+
```
|
|
77
298
|
|
|
78
|
-
|
|
299
|
+
## License
|
|
79
300
|
|
|
80
|
-
|
|
81
|
-
Last update 2011-10-16
|
|
82
|
-
</section>
|
|
301
|
+
This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
|
83
302
|
|
|
303
|
+
© 2011-2019 Matthias Günther <matze@wikimatze.de>.
|
data/Rakefile
CHANGED
data/lib/sweetie/bitbucket.rb
CHANGED
|
@@ -1,207 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require 'sweetie/helper'
|
|
2
|
+
require 'sweetie/bitbucket_stati_helper'
|
|
3
|
+
require 'json'
|
|
3
4
|
|
|
5
|
+
module Sweetie
|
|
6
|
+
# The class to get the repositorie updates from Bitbucket
|
|
4
7
|
class Bitbucket
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
# bitbucket('wikimatze')
|
|
29
|
-
#
|
|
30
|
-
# Returns nothing but write the changes in the _config.yml file
|
|
31
|
-
def bitbucket(user)
|
|
32
|
-
json_repositories = get_repositories(user)
|
|
33
|
-
repositories_change_hashs = get_repositories_changes(json_repositories)
|
|
34
|
-
write_repository_changes(repositories_change_hashs)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Public: Fire up curl request to bitbucket
|
|
38
|
-
#
|
|
39
|
-
# user - The String of the bitbucket user
|
|
40
|
-
#
|
|
41
|
-
# Example:
|
|
42
|
-
#
|
|
43
|
-
# bitbucket('wikimatze')
|
|
44
|
-
#
|
|
45
|
-
# # =>
|
|
46
|
-
# {
|
|
47
|
-
# "repositories": [
|
|
48
|
-
# {
|
|
49
|
-
# "scm": "git",
|
|
50
|
-
# "has_wiki": false,
|
|
51
|
-
# "last_updated": "2012-07-01 07:03:08",
|
|
52
|
-
# "creator": null,
|
|
53
|
-
# "created_on": "2012-07-01 07:03:08",
|
|
54
|
-
# "owner": "wikimatze",
|
|
55
|
-
# "logo": null,
|
|
56
|
-
# "email_mailinglist": "",
|
|
57
|
-
# "is_mq": false,
|
|
58
|
-
# "size": 580,
|
|
59
|
-
# "read_only": false,
|
|
60
|
-
# "fork_of": null,
|
|
61
|
-
# "mq_of": null,
|
|
62
|
-
# "followers_count": 1,
|
|
63
|
-
# "state": "available",
|
|
64
|
-
# "utc_created_on": "2012-07-01 05:03:08+00:00",
|
|
65
|
-
# "website": "",
|
|
66
|
-
# "description": "",
|
|
67
|
-
# "has_issues": false,
|
|
68
|
-
# "is_fork": false,
|
|
69
|
-
# "slug": "knoppix-6-01",
|
|
70
|
-
# "is_private": false,
|
|
71
|
-
# "name": "knoppix-6-01",
|
|
72
|
-
# "language": "",
|
|
73
|
-
# "utc_last_updated": "2012-07-01 05:03:08+00:00",
|
|
74
|
-
# "email_writers": true,
|
|
75
|
-
# "no_public_forks": false,
|
|
76
|
-
# "resource_uri": "/1.0/repositories/wikimatze/knoppix-6-01"
|
|
77
|
-
# },
|
|
78
|
-
# ... other repositories
|
|
79
|
-
# }
|
|
80
|
-
# ],
|
|
81
|
-
# "user": {
|
|
82
|
-
# "username": "wikimatze",
|
|
83
|
-
# "first_name": "Matthias",
|
|
84
|
-
# "last_name": "Guenther",
|
|
85
|
-
# "avatar": "https://secure.gravatar.com/avatar/208673d619b63131cbfd7205366ad16e?d=identicon&s=32",
|
|
86
|
-
# "resource_uri": "/1.0/users/wikimatze"
|
|
87
|
-
# }
|
|
88
|
-
# }
|
|
89
|
-
#
|
|
90
|
-
# Returns a json representation the specified user
|
|
91
|
-
def get_repositories(user)
|
|
92
|
-
`curl -s https://api.bitbucket.org/1.0/users/#{user}/`
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Public: Grab for each repository the recent update
|
|
96
|
-
#
|
|
97
|
-
# json_repositories: A json object of the bitbucket API response
|
|
98
|
-
#
|
|
99
|
-
# Example:
|
|
100
|
-
#
|
|
101
|
-
# get_repositories_changes(wikimatze_json)
|
|
102
|
-
# # => {"pmwiki-headlineimage-recipe"=>"2011-10-29", "pmwiki-linkicons-recipe"=>"2011-10-29"}
|
|
103
|
-
#
|
|
104
|
-
# Returns a hash of the form {repository_name => last_updated}
|
|
105
|
-
def get_repositories_changes(json_repositories)
|
|
106
|
-
repository_hash = parse_json(json_repositories)
|
|
107
|
-
repositories_changsets = {}
|
|
108
|
-
|
|
109
|
-
repository_hash["repositories"].each do |repository|
|
|
110
|
-
repository_name = repository['name']
|
|
111
|
-
repository_last_updated = parse_timestamp(repository['last_updated'])
|
|
112
|
-
repositories_changsets.merge!({repository_name => repository_last_updated})
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
repositories_changsets
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Public: Wrapper for calling the json_parsing
|
|
119
|
-
#
|
|
120
|
-
# file: A String in JSON format
|
|
121
|
-
#
|
|
122
|
-
# Example:
|
|
123
|
-
#
|
|
124
|
-
# json = {
|
|
125
|
-
# "user": {
|
|
126
|
-
# "username": "wikimatze",
|
|
127
|
-
# "first_name": "Matthias",
|
|
128
|
-
# "last_name": "Guenther",
|
|
129
|
-
# "resource_uri": "/1.0/users/wikimatze"
|
|
130
|
-
# }
|
|
131
|
-
# }
|
|
132
|
-
|
|
133
|
-
# parse_json(json)
|
|
134
|
-
# # => {"user"=>{"username"=>"wikimatze", "first_name"=>"Matthias", "last_name"=>"Guenther", "resource_uri"=>"/1.0/users/wikimatze"}}
|
|
135
|
-
#
|
|
136
|
-
# Returns Parse JSON file to format be read by ruby
|
|
137
|
-
def parse_json(json)
|
|
138
|
-
JSON.parse(json)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Public: Parse a timestamp in a wanted format
|
|
142
|
-
#
|
|
143
|
-
# timestamp - A string in the form 2011-04-20 11:31:39
|
|
144
|
-
#
|
|
145
|
-
# Example:
|
|
146
|
-
#
|
|
147
|
-
# parse_timestamp("2011-04-20 11:31:39")
|
|
148
|
-
# # => 2011-04-20
|
|
149
|
-
#
|
|
150
|
-
# Returns a string in the format "yyyy-mm-dd"
|
|
151
|
-
def parse_timestamp(timestamp)
|
|
152
|
-
regex = Regexp.new(/(\d+)-(\d+)-(\d+)/)
|
|
153
|
-
regex.match(timestamp)[0]
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
# Public: Parse a hash and write its key/value pairs in a file
|
|
157
|
-
#
|
|
158
|
-
# repositories - A hash in the form {<name> => <last_updated}
|
|
159
|
-
#
|
|
160
|
-
# Example:
|
|
161
|
-
#
|
|
162
|
-
# write_repository_changes({"svn" => "2011-10-26", "pmwiki" => "2011-10-26"})
|
|
163
|
-
# # => svn: 2011-10-26\npmwiki: 2011-10-26
|
|
164
|
-
#
|
|
165
|
-
# Returns nothing but writes the information in the specified _config.yml file
|
|
166
|
-
def write_repository_changes(repositories)
|
|
167
|
-
repositories.each do |name, last_updated|
|
|
168
|
-
file = File.open(@@config)
|
|
169
|
-
text = ""
|
|
170
|
-
match = false
|
|
171
|
-
while line = file.gets
|
|
172
|
-
if line.match(/#{name}/)
|
|
173
|
-
match = true
|
|
174
|
-
# create string and replace this line with the new changes
|
|
175
|
-
text << entry_text(name, last_updated) + "\n"
|
|
176
|
-
else
|
|
177
|
-
text << line
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
# append the name if it is not in there
|
|
182
|
-
text << entry_text(name, last_updated) unless match
|
|
183
|
-
|
|
184
|
-
file.close
|
|
185
|
-
write_config(@@config, text)
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
# Public: Create a string representation of a repository entry
|
|
190
|
-
#
|
|
191
|
-
# name - A string containing the name of the repository
|
|
192
|
-
# last_updated - A string containing the date of the last change of the repo
|
|
193
|
-
#
|
|
194
|
-
# Example:
|
|
195
|
-
#
|
|
196
|
-
# entry_text({"pmwiki" => "2011-10-26"}
|
|
197
|
-
# # => "pmwiki: 2011-10-26"
|
|
198
|
-
#
|
|
199
|
-
# Return a string in the form "<name>: <last_updated>"
|
|
200
|
-
def entry_text(name, last_updated)
|
|
201
|
-
"#{name}: #{last_updated}"
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
end # self
|
|
205
|
-
end # Bitbucket
|
|
206
|
-
end # Sweetie
|
|
8
|
+
include Sweetie::Helper
|
|
9
|
+
|
|
10
|
+
# A basic initialize method.
|
|
11
|
+
#
|
|
12
|
+
# @param bitbucket_stati_helper [BitbucketStatiHelper]
|
|
13
|
+
# @return [BitbucketStatiHelper]
|
|
14
|
+
def initialize(bitbucket_stati_helper)
|
|
15
|
+
@bitbucket_stati_helper = bitbucket_stati_helper
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Wrapper to start all the other methods which will use methods
|
|
19
|
+
# to write the changes of the bitbucket in the config file,
|
|
20
|
+
# which can be configured in the BitbucketStatiHelper
|
|
21
|
+
#
|
|
22
|
+
# @return [nil]
|
|
23
|
+
def update_stati
|
|
24
|
+
json_repositories = @bitbucket_stati_helper.get_repositories
|
|
25
|
+
repositories_change_hashs = @bitbucket_stati_helper.get_repositories_changes(json_repositories)
|
|
26
|
+
@bitbucket_stati_helper.write_repository_changes(repositories_change_hashs)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
207
30
|
|