wikimatze / sweetie

Count pages, images, links, and last-build time of a jekyll project

Home Page:https://rubygems.org/gems/sweetie/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sweetie is a plugin for to get statistics for jekyll and middleman projects. The statistics includes the unique number of all links, images, pages, and the last build time of the given project. You can specify the location the generated files (normally _site for jekyll and build for middleman apps) and of the config file where the changes will be written.

It can also grab the last changes of your bitbucket repositories. You can then use the information on various places in your project

Gem Version CircleCI

Toc

Installation

$ gem install sweetie

Usage create stati

Jekyll

The easiest way is to add require 'sweetie' on the top of your Rakefile.

Before you build your page, you can run a rake task to update the status information of a page:

require 'sweetie'

desc 'write stats in the _config.yml file'
task :create_stati do
  sweetie = Sweetie::Conversion.new('./site', './_config.yml')
  sweetie.create_stati
end

Make sure that the following fields are set in your _config.yml:

build:
htmlpages:
images:
links:

After running the script, the changes in _config.yml will look like:

build: 6-18-2017
htmlpages: 600
images: 20
links: 271

Configuration variables for Jekyll

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:

  • {{ site.build }}
  • {{ site.htmlpages }}
  • {{ site.images }}
  • {{ site.links }}

If you also make use of Usage for Bitbucket repositories you can also use the last update value for your repositories:

<section class="lastupdate">
Last update {{ site.git }}
</section>
...


<section class="lastupdate">
Last update {{ site.pmwiki-twitter-recipe }}
</section>
...

will result the following html:

<h3 id="git">Git</h3>

<section class="lastupdate">
Last update 2011-10-16
</section>


<h3 id="twitter">Twitter</h3>

<section class="lastupdate">
Last update 2011-10-16
</section>

Middleman

The easiest way is to add require 'sweetie' on the top of your Rakefile.

Before you build your page, you can run a rake task to update the status information of a page:

require 'sweetie'

desc 'write stats in the config.rb file'
task :create_stati do
  sweetie = Sweetie::Conversion.new('./build', './config.rb')
  sweetie.create_stati
end

Make sure that the following fields are set in your config.rb:

set :build,
set :images,
set :htmlpages,
set :links,

After running the script, the changes in config.rb will look like for example:

set :build, 6-18-2017
set :images, 75
set :htmlpages, 111
set :links, 694

Configuration variables for Middleman

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:

  • `<%= config[:build] %>
  • `<%= config[:htmlpages] %>
  • `<%= config[:images] %>
  • `<%= config[:links] %>

If you also make use of Usage for Bitbucket repositories you can also use the last update value for your repositories:

<section class="lastupdate">
Last update <%= config[:git] %>
</section>
...


<section class="lastupdate">
Last update <%= config[:pmwiki_twitter_recipe %>
</section>
...

will result the following html:

<h3 id="git">Git</h3>

<section class="lastupdate">
Last update 2011-10-16
</section>


<h3 id="twitter">Twitter</h3>

<section class="lastupdate">
Last update 2011-10-16
</section>

Usage Bitbucket repositories

Middleman

The easiest way is to add require 'sweetie' on the top of your Rakefile.

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:

require 'sweetie'

desc 'write repositories stats in the config.rb file'
task :create_bitbucket do
  stati_helper = Sweetie::BitbucketStatiHelper.new('./config.rb', 'wikimatze')
  bitbucket = Sweetie::Bitbucket.new(stati_helper)
  bitbucket.update_stati
end

Please note that you have to change wikimatze to your bitbucket user name

set :pmwiki_dropcaps_recipe,
set :pmwiki_syntaxlove_recipe,
set :pmwiki_twitter_recipe,
set :pmwiki_linkicons_recipe,
set :pmwiki_headlineimage_recipe,

After running the script, the names in config.rb above will be changed to:

set :pmwiki_dropcaps_recipe, 2017-02-24
set :pmwiki_syntaxlove_recipe, 2017-02-26
set :pmwiki_twitter_recipe, 2017-02-26
set :pmwiki_linkicons_recipe, 2017-02-26
set :pmwiki_headlineimage_recipe, 2017-02-25

Jekyll

The easiest way is to add require 'sweetie' on the top of your Rakefile.

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:

require 'sweetie'

desc 'write repositories stats in the _config.yml file'
desc 'write stats in the _config.yml'
task :create_bitbucket do
  stati_helper = Sweetie::BitbucketStatiHelper.new('./_config.yml', 'wikimatze')
  bitbucket = Sweetie::Bitbucket.new(stati_helper)
  bitbucket.update_stati
end

Please note that you have to change wikimatze to your bitbucket user name

set :pmwiki_dropcaps_recipe,
set :pmwiki_syntaxlove_recipe,
set :pmwiki_twitter_recipe,
set :pmwiki_linkicons_recipe,
set :pmwiki_headlineimage_recipe,

After running the script, the names in config.rb above will be changed to:

set :pmwiki_dropcaps_recipe, 2017-02-24
set :pmwiki_syntaxlove_recipe, 2017-02-26
set :pmwiki_twitter_recipe, 2017-02-26
set :pmwiki_linkicons_recipe, 2017-02-26
set :pmwiki_headlineimage_recipe, 2017-02-25

License

This software is licensed under the MIT license.

© 2011-2022 Matthias Günther matze@wikimatze.de.

About

Count pages, images, links, and last-build time of a jekyll project

https://rubygems.org/gems/sweetie/


Languages

Language:Ruby 100.0%