{"id":15406786,"url":"https://github.com/dannyben/bobkit","last_synced_at":"2025-04-18T02:58:15.228Z","repository":{"id":7422151,"uuid":"56345806","full_name":"DannyBen/bobkit","owner":"DannyBen","description":"Site Generation Toolkit with Slim, SCSS, CoffeeScript and Markdown","archived":false,"fork":false,"pushed_at":"2024-02-29T07:53:19.000Z","size":164,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T16:46:15.835Z","etag":null,"topics":["gem","ruby","site-generator"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DannyBen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-15T19:48:13.000Z","updated_at":"2023-11-29T12:12:46.000Z","dependencies_parsed_at":"2024-02-29T08:50:55.895Z","dependency_job_id":null,"html_url":"https://github.com/DannyBen/bobkit","commit_stats":{"total_commits":120,"total_committers":4,"mean_commits":30.0,"dds":"0.30833333333333335","last_synced_commit":"7cebbacd86f634671c9a01461f509ccb8a9b26e2"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fbobkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fbobkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fbobkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fbobkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/bobkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249417159,"owners_count":21268205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","ruby","site-generator"],"created_at":"2024-10-01T16:25:22.294Z","updated_at":"2025-04-18T02:58:15.214Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bobkit - Site Generation Toolkit\r\n\r\n[![Gem Version](https://badge.fury.io/rb/bobkit.svg)](https://badge.fury.io/rb/bobkit)\r\n[![Build Status](https://github.com/DannyBen/bobkit/workflows/Test/badge.svg)](https://github.com/DannyBen/bobkit/actions?query=workflow%3ATest)\r\n[![Maintainability](https://api.codeclimate.com/v1/badges/64c20ebaaf8ecff0948d/maintainability)](https://codeclimate.com/github/DannyBen/bobkit/maintainability)\r\n\r\n---\r\n\r\nBobkit is a lightweight toolkit for generating static websites with:\r\n\r\n#### `Slim + SCSS + CoffeeScript + Markdown + I18n`\r\n\r\n---\r\n\r\nThe design intentions were to:\r\n\r\n- Provide easy to use wrapper methods for Slim, SCSS, CoffeeScript and \r\n  Markdown.\r\n- Not impose any directory structure (this is not another blog generator...).\r\n- Allow you to use standard ruby for generating your site how you see fit.\r\n- Be packaged as a library, and not a command line tool.\r\n- Provide sensible default locations that are easily overridable.\r\n- Add `render` and `layout` support to Slim (Rails-like).\r\n- Add i18n support to Slim (Rails-like).\r\n- Add `@import 'globbing/*'` support to SCSS (Rails-like).\r\n\r\n---\r\n\r\n\r\n\r\n## Install\r\n\r\n`gem install bobkit`\r\n\r\nOr with Bundler:\r\n\r\n`gem 'bobkit'`\r\n\r\n\r\n\r\n## Usage\r\n\r\nThe basic usage pattern is this:\r\n\r\n- Create a ruby file and include Bobkit\r\n- Create your input folders (for Slim templates, SCSS files etc.) \r\n  wherever you want (or use the default locations, see below).\r\n- In your Ruby script, call Bobkit methods to generate your site.\r\n\r\n### Example\r\n\r\n```ruby\r\nrequire 'bobkit'\r\ninclude Bobkit::Tasks\r\n\r\n# Convert Slim to HTML string\r\nhtml = render 'youtube', video: 'hi9tOILaiNs'\r\nputs html\r\n\r\n# Convert Slim to HTML file\r\n# This will use 'templates/youtube.slim', with the layout file\r\n# `templates/layouts/default.slim` and will generate 'output/bobcat.html'.\r\nrender 'youtube', layout: 'default', video: 'hi9tOILaiNs', output: 'bobcat'\r\n\r\n# Compile SCSS\r\n# This will convert `styles/main.scss` to `output/css/style.css`\r\ncompile_css 'main', output: 'style'\r\n```\r\n\r\nSee more examples in the [Examples folder][1]\r\n\r\n\r\n### DSL or Instance\r\n\r\nBobkit was primarily designed as a DSL, but if you wish to use a more scoped\r\napproach, you can use an instance of the `Bob` class.\r\n\r\n```ruby\r\nrequire 'bobkit'\r\n\r\n# Option 1: DSL\r\ninclude Bobkit::Tasks\r\nrender ...\r\ncompile_css ...\r\n\r\n# Option 2: Bob class\r\nbob = Bob.new\r\nbob.render ...\r\nbob.compile_css ...\r\n```\r\n\r\n## Reference\r\n\r\n### Setting folder locations and options\r\n\r\nBobkit has defaults for everything, but you can easily change them.\r\nEach of these methods can be called with or without a parameter. When\r\ncalled without a parameter, it will simply return the value.\r\n\r\n```ruby\r\n# Base location of all other folders. Default: \".\"\r\nroot_folder 'my_app'\r\n\r\n# Location of source Slim templates. Default: \"templates\"\r\ntemplates_folder 'views'\r\n\r\n# Location of source Slim templates for layouts. \r\n# Default: \"#{templates_folder}/layouts\"\r\nlayouts_folder 'my_layouts'\r\n\r\n# Location of markdown files. Default: \"markdown\"\r\nmarkdown_folder 'docs'\r\n\r\n# Location of the source SCSS files. Default: \"styles\"\r\nstyles_folder 'styles'\r\n\r\n# Location of locale configuration files. Default: \"locales\"\r\nlocales_folder 'locales'\r\n\r\n# Output location. Default: \"output\"\r\noutput_folder 'site'\r\n\r\n# Output location for CSS. Default: \"#{output_folder}/css\"\r\ncss_output_folder \"#{output_folder}/stylesheets\"\r\n\r\n# Location of other source asset files (images etc.). Default: 'assets'\r\nassets_folder 'files'\r\n\r\n# Output location for assets. Default: \"#{output_folder}/assets\"\r\nassets_output_folder 'images'\r\n\r\n# Options for Slim generation.\r\nslim_options pretty: true, disable_escape: true\r\n\r\n# Options for SCSS generation.\r\nscss_options cache: true, syntax: :scss, style: :nested\r\n\r\n# Restore all settings to defaults\r\nuse_defaults\r\n```\r\n\r\n### Slim \r\n\r\n```ruby\r\n# You can set a scope before calling any `render`\r\nscope CatVideo.new\r\nhtml = render 'cats'\r\n\r\n# You can use a hash as scope\r\nscope email: 'bob@kit.com', name: 'Bob'\r\nhtml = render 'user'\r\n\r\n# You can render an object that responds to 'to_partial'\r\n# This method should return the name of the partial file\r\nuser = User.new\r\nhtml = render user\r\n\r\n# You can send a scope directly to `render`\r\nhtml = render 'user', email: 'bob@kit.com', name: 'Bob'\r\n\r\n# You can render with a layout\r\nhtml = render 'user', layout: 'default', email: 'bob@kit.com'\r\n\r\n# You can save to a file in the `output_folder`\r\nrender 'user', layout: 'default', email: 'bob@kit.com', output: 'bob'\r\n\r\n# You can send an HTML string as the content of a layout\r\nrender content: \"\u003ch1\u003eHello\u003c/h1\u003e\", layout: 'default'\r\n```\r\n\r\nIn addition, you can call `= render 'template'` from inside a slim \r\ntemplate. \r\n\r\nTo check if a certain context variable was provided to a slim template,\r\nyou can use `if have? :varname`.\r\n\r\n### SCSS\r\n\r\n```ruby\r\n# You can compile SCSS to a CSS string, to do as you please with it\r\ncss = compile_css 'style'\r\n\r\n# You can compile SCSS directly to a file\r\ncompile_css 'style', output: 'main'\r\n```\r\n\r\n### CoffeeScript\r\n\r\n```ruby\r\n# You can compile CoffeeScript to a Javascript string\r\njs = compile_js 'script'\r\n\r\n# You can compile CoffeeScript directly to a file\r\ncompile_js 'script', output: 'main'\r\n```\r\n\r\n### Markdown\r\n\r\n```ruby\r\n# Compile a markdown file to HTML string\r\nhtml = markdown 'article'\r\n\r\n# Compile directly to a file, inside a slim layout\r\nmarkdown 'article', layout: :default, output: 'article'\r\n\r\n# All options pass through directly to the slim renderer\r\nhtml = markdown 'article', layout: :default, sidebar: true\r\n```\r\n\r\n### Asset helpers\r\n\r\nAnything other than CSS, Javascript and HTML is considered an asset.\r\nThese are some helpers to help you move them around from input to output\r\nfolders.\r\n\r\n```ruby\r\n# Copy a file from the `assets_folder` to the `assets_output_folder`\r\ncopy_asset 'presskit.zip'\r\n\r\n# Copy a folder\r\ncopy_asset 'images'\r\n```\r\n\r\n### Internationalization (I18n)\r\n\r\nBobkit supports these i18n features:\r\n\r\n- Set the folder for your localization files with `locales_folder` \r\n  (default: 'locales').\r\n- You can call `= t('common.hello')` from a slim template.\r\n- You can call `= l(Time.now)` from a slim template.\r\n- Any call to `render 'template_name'` will first look for a localized\r\n  version of the file (`template_name.en.slim`) and will use it if found.\r\n  Otherwise, it will use the unlozalized filename (`template_name.slim`).\r\n\r\n\r\n### Low level file and folder helpers\r\n\r\nIf you want more control over what the `copy_asset` method provides, you\r\ncan use any of these methods.\r\n\r\n```ruby\r\n# Copy a file - needed parent folders will be created as needed\r\ncopy_file 'exact/path.zip', 'exact/output/file.zip'\r\n\r\n# Copy a folder - needed parent folders will be created as needed\r\ncopy_folder 'exact/path', 'exact/output/folder'\r\n\r\n# Create folder, and any of the needed parent folders\r\ncreate_folder 'my_folder'\r\n\r\n# Create folder for a file, with any of the needed parent folders\r\ncreate_folder_for 'some/folder/with/file.png'\r\n```\r\n\r\n### File Watcher\r\n\r\nBobkit comes bundled with FileWatcher, and has a shortcut method to \r\nuse it.\r\n\r\n```ruby\r\ninclude Bobkit::Watcher\r\n\r\nwatch do |changes|\r\n  changes do |filename, event|\r\n    puts \"#{event}: #{filename}\"\r\n    generate\r\n  end\r\nend\r\n\r\ndef generate\r\n  # Your generation logic here\r\nend\r\n```\r\n\r\nThe watch command is just like \r\n`Filewatcher.new([...]).watch() do |filename, event|`\r\nwith the exception that the array of paths to watch is optional. If none\r\nprovided, we will watch all the input folders.\r\n\r\n\r\n[1]: https://github.com/DannyBen/bobkit/tree/master/examples\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fbobkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fbobkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fbobkit/lists"}