Giter Site home page Giter Site logo

recurser / jekyll-plugins Goto Github PK

View Code? Open in Web Editor NEW
217.0 17.0 52.0 176 KB

A collection of Jekyll plugins and generators that I've written for recursive-design.com

Home Page: http://www.daveperrett.com/articles/2010/12/08/jekyll-plugins-for-categories-projects-and-sitemaps/

License: MIT License

Ruby 100.00%

jekyll-plugins's Introduction

About

This is a collection of Jekyll plugins and generators that I've written for use on daveperrett.com.

License

The plugins are distributed under the MIT License. See the License file for details.

Installation

To install the plugins simply put them in a directory named _plugins in your project directory.

Bug Reports

If you come across any problems, please create a ticket and we'll try to get it fixed as soon as possible.

Want to make your own plugins?

More information on the Jekyll plugin architecture is available from the Jekyll wiki.

generate_projects.rb

A generator that creates project pages for Jekyll sites from git repositories.

This was inspired by the project pages on GitHub, which use the project README file as the index page. It takes git repositories, and automatically builds project pages for them using the README file, along with downloadable zipped copies of the projects themselves (for example, the project page for this plugin repository is auto-generated with this plugin).

Usage

To use it, simply drop the generate_projects.rb script into the _plugins directory of your Jekyll site. Next, create a _projects folder in the base of your Jekyll site. This folder should contain .yml files describing how to build a page for your project. Here is an example _projects/jekyll-plugins.yml):

layout:     default
title:      Jekyll Plugins
repository: git://daveperrett.com/jekyll-plugins.git
published:  true

How it works

When you compile your Jekyll site, the plugin will download the git repository of each project in your _projects folder, create an index page from the README file (using the specified layout), and create a downloadable .zip file of the project. The goal is to automate the construction of online project pages, keep them in sync with README documentation, and provide an up-to-date zip archive for download.

Required files

Your project's git repository should contain:

  • README : The contents of this will be used as the body of your project page will be created from. Any extension other than .markdown, .textile or .html will be treated as a .textile file.
  • versions.txt : Contains the version string (eg 1.0.0). Used when naming the downloadable zip-file (optional). If the version.txt file is not available, a YYYYMMDDHHMM timestamp will be used for the version instead.

Required gems

  • git (>= 1.2.5)
  • rubyzip (>= 0.9.4)

Available _config.yml settings

  • project_dir : The subfolder to compile projects to (default is 'projects').

Available YAML settings

  • repository : Git repository of your project (required).
  • layout : Layout to use when creating the project page.
  • title : Project title, which can be accessed in the layout.
  • published : Project won't be published if this is false.

There is also an optional zip_folder_name setting, in case you want the unzipped folder to be named something other than the project name. This is useful (for eaxmple) if you want it to unzip as an OS X 'Something.app' application bundle.

generate_categories.rb

A generator that creates category pages for Jekyll sites (for example our plugin category).

Usage

To use it, simply drop the generate_categories.rb script into the _plugins directory of your Jekyll site.

You should also copy the category_index.html file to the _layouts directory of your own project. This file is provided as an example layout, and obviously you can change the HTML as you see fit.

You can also (optionally) generate an atom.xml feed for each category. To do this, copy the category_feed.xml file to the _includes/custom directory of your own project. You'll also need to copy the octopress_filters.rb file into the _plugins directory of your project, as the category_feed.xml requires a couple of extra filters.

How it works

When you compile your Jekyll site, this plugin will loop through the list of categories in your site, and use the layout above to generate a page for each one with a list of links to the individual posts.

Included filters

  • category_links : Outputs the list of categories as comma-separated links.
  • date_to_html_string : Outputs the post.date as formatted html, with hooks for CSS styling.

Available _config.yml settings

  • category_dir : The subfolder to build category pages in (default is 'categories').
  • category_title_prefix : The string used before the category name in the page title (default is 'Category: ').

generate_sitemap.rb

A simple generator that creates a sitemap.xml page for Jekyll sites, suitable for submission to Google etc (for example the sitemap.xml for daveperrett.com.

Usage

To use it, simply drop the generate_sitemap.rb script into the _plugins directory of your Jekyll site.

How it works

When you compile your Jekyll site, the plugin will loop through the list of pages in your site, and generate an entry in sitemap.xml for each one.

Available YAML settings

  • changefreq : How often this page will change. This setting is optional, but if specified its value must be one of always, hourly, daily, weekly, monthly, yearly, or never. See the sitemap specification for more details on what this is used for. By default, this property is omitted for static pages and never for the files in _posts (since these are typically blog entries or the like).

Change history

  • Version 0.2.1 (2012-10-15) : Merged some updates from Octopress back in.
    • Add support for atom.xml feed generation for categories.
    • Improved handling of multibyte and multi-word category names in URLs.
  • Version 0.2.0 (2012-10-14) :
    • Add support for priority in generate_sitemap.rb (thanks hez!).
    • Remove hard-coded category directory in generate_categories.rb (thanks ghinda and MrWerewolf!).
    • Improved slash handling in generate_sitemap.rb.
  • Version 0.1.8 (2011-08-15) : A bunch of fixes and improvements (thanks bdesham!).
  • Version 0.1.7 (2011-07-19) : Sitemap base URL fix (thanks ojilles!).
  • Version 0.1.6 (2011-05-21) : Added optional zip_folder_name YAML config setting.
  • Version 0.1.5 (2011-05-21) : Replace github-style code markup to pygments-compatible 'highlight' format.
  • Version 0.1.4 (2011-05-08) : Applied patch to fix permalink problem in generate_sitemap.rb (thanks ejel!).
  • Version 0.1.3 (2011-01-06) : Fixed pygments code formatting bug introduced in generate_projects.rb v0.1.2.
  • Version 0.1.2 (2011-01-06) : Add generated pages to the Site::pages list, to stop them being deleted automatically by Site::cleanup(); Fixed a file extension problem with generate_projects.rb.
  • Version 0.1.1 (2010-12-10) : Use mtime instead of ctime for sitemap modification dates; Fixed sitemap extension bug.
  • Version 0.1.0 (2010-12-08) : Initial release.

Contributing

Once you've made your commits:

  1. Fork jekyll-plugins
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a Pull Request from your branch
  5. That's it!

Author

Dave Perrett :: [email protected] :: @daveperrett

Copyright

Copyright (c) 2010 Dave Perrett. See License for details.

jekyll-plugins's People

Contributors

hez avatar kemayo avatar ojilles avatar recurser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-plugins's Issues

Anyway to tweak the category plugin to include pages?

The category plugin works great for posts, but how about pages? I'm using Jekyll as a knowledgebase, using categories (tags actually) with pages. I was trying to find a way to auto-generate tag archives for pages. Could this category plugin somehow be adjusted to include pages?

Pagination and generate_sitemap.rb

When adding pagination to jekyll, generate_sitemap breaks. The following error is returned.

$ jekyll --server
/Users/bhardin/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': iconv will be deprecated in the future, use String#encode instead.
Configuration from /Users/bhardin/Documents/projects/blog/_config.yml
Building site: /Users/bhardin/Documents/projects/blog -> /Users/bhardin/Documents/projects/blog/_site
/Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:85:in `mtime': No such file or directory - /Users/bhardin/Documents/projects/blog/page2/index.html (Errno::ENOENT)
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:85:in `block in generate_content'
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:83:in `each'
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:83:in `generate_content'
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:60:in `block in generate'
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:58:in `open'
        from /Users/bhardin/Documents/projects/blog/_plugins/generate_sitemap.rb:58:in `generate'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/gems/jekyll-0.11.2/lib/jekyll/site.rb:184:in `block in generate'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/gems/jekyll-0.11.2/lib/jekyll/site.rb:183:in `each'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/gems/jekyll-0.11.2/lib/jekyll/site.rb:183:in `generate'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/gems/jekyll-0.11.2/lib/jekyll/site.rb:39:in `process'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/gems/jekyll-0.11.2/bin/jekyll:250:in `<top (required)>'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/bin/jekyll:19:in `load'
        from /Users/bhardin/.rvm/gems/ruby-1.9.3-p0/bin/jekyll:19:in `<main>'

Issue in Jekyll: jekyll/jekyll#501

Generate_Project.rb not working (here)

I have the plugin and required gems, starting jekyll I get no errors and the message which tells you the project is being cloned ( I've checked on /tmp and it's there) but when I look into the site folder there's no projects folder or anything alike.

what should I check to make it work properly?

post-receive hook and jekyll-plugins

I am having some issues when i deploy my website via a post-receive hook to my linode server. I am using the generate_sitemap.rb and generate_categories.rb plugins. when i generate my website on local machine it all works fine. but when i deploy the website, the sitemap.xml does not get generated and neither do the categories work. help please..

error running jekyll when using generate_projects plugin

When i try to run jekyll using the generate_projects.rb plugin i get this message error:

building site: /home/yc/private/dev/jekyll/example-app -> /home/cyounes/private/dev/jekyll/example-app/_site
/home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:144:in `clone_repo': uninitialized constant Jekyll::ProjectIndex::Pathname (NameError)
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:95:in `initialize'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:265:in `new'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:265:in `write_project_index'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:255:in `block in write_project_indexes'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:253:in `each'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:253:in `write_project_indexes'
        from /home/yc/private/dev/jekyll/example-app/_plugins/generate_projects.rb:307:in `generate'
        from /var/lib/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:184:in `block in generate'
        from /var/lib/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:183:in `each'
        from /var/lib/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:183:in `generate'
        from /var/lib/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:39:in `process'
        from /var/lib/gems/1.9.1/gems/jekyll-0.11.2/bin/jekyll:250:in `<top (required)>'
        from /usr/local/bin/jekyll:23:in `load'
        from /usr/local/bin/jekyll:23:in `<main>'


I got this error on both Ubuntu and Mac OS !
when i run jekyll server with auto option , it ran without any problem but i didn't find any generated project page on the projects folder?

Need to use layout: null

With the newer versions of Octopress the xml layout needs to be null instead of nil. Otherwise a warning will be generated during generation for every category.


---
layout: null

---

Load Error when jekyll tries to install generate-projects.rb

I got the following message when jekyll tried to install the generate-projects.rb (I'm running the build in Travis CI):

home/travis/build/jputrino/f5-openstack-docs/_plugins/generate_projects.rb:64:in `require': cannot load such file -- zip/zip (LoadError)
    from /home/travis/build/jputrino/f5-openstack-docs/_plugins/generate_projects.rb:64:in `<top (required)>'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:74:in `require'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:74:in `block (2 levels) in require_plugin_files'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:73:in `each'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:73:in `block in require_plugin_files'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:72:in `each'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:72:in `require_plugin_files'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:18:in `conscientious_require'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:79:in `setup'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:41:in `initialize'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:29:in `new'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:29:in `process'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /home/travis/.rvm/gems/ruby-2.2.0/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /home/travis/.rvm/gems/ruby-2.2.0/bin/jekyll:23:in `load'
    from /home/travis/.rvm/gems/ruby-2.2.0/bin/jekyll:23:in `<main>'
    from /home/travis/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
    from /home/travis/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'

The command "./script/cibuild.sh" exited with 1.

Jekyll hangs with a slightly modified version of the generate_categories.rb plugin

I use the generate_categories.rb plugin from here to generate categories. However, if a category contains spaces I would like it's directory to be created with underscores.

For example, a category named "Metro Design Language" should be created in directory "Metro_Design_Language".

I took the original code and modified line 97,

from:

self.write_category_index(File.join(dir, category), category)

to:

self.write_category_index(File.join(dir, category.gsub(' ','_')), category)

However, for some reason now Jekyll can't generate the _site contents. After generating a few categories (with their indexes) it hangs.

I am new to Ruby and Jekyll, so any advice on this would be much appreciated.

(I have also created a question on Stack Overflow.)

Categories regexp.

If you're going to add 2 categories like "C++" and "C#" this plugin is going to work incorrectly.
Now there is regexp:

category = category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase

Both categories are going to generate "c-" as category name and the file with category will be overwritten.

I think this should be something like (and it's working for me):

category = URI::encode(category).downcase

Error: Pygments can't parse unknown language: php</p>

For some reason, when the plugin tries to generate the xml feeds for the categories Pygments tries to parse the code blocks, but they've already been wrapped in <p> tags which results in the following when using rake generate

Error: Pygments can't parse unknown language: php</p>

The generated xml file contains this in the <content> tag

<p>```php</p>

This blocks the site from being generated and as such any changes become 'undeployable' blocking any updates to the site.

Issue building a link of to category posts

I use your script generate_categories.rb but it seems I'm having this trouble:

On local:
I successfully build and navigate to localhost:4000/categories/programming which renders category_index.html and programming is my category in this case. Seems good so far.

However, on remote after build:
The link http://mysite.github.io/categories/programming redirects to not found 404 page. This troubles me and I'm looking for a way to debug or configure this. Any advice? Thank you.

content is not render by using markdown

I installed this plugin, but found that the generated category page do not render the post content correctly.

my post file is a markdown, is there any idea how to enable this function?

Question: Category List

Hello, I would like to know which would be the proper way to generate a Category List index with all the categories of the site.

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.