Rack Application to serve a simple blog
This is just a project for learning purpose, but if you want to use it read further. Code should be considered bad (1st ruby project). Also its not actively maintained.
- rbx > 3.14
- ruby > 2.2
$ gem install rack-blogengine
rack-blogengine generate <folder>
will create your Folder skeleton
These folders and files will be created for you
targetfolder/assets
targetfolder/assets/style
targetfolder/assets/js
targetfolder/assets/layout
targetfolder/assets/images
targetfolder/operator
targetfolder/assets/style/style.css
targetfolder/assets/js/script.js
targetfolder/assets/layout/layout.html
(filled with basic structure)
targetfolder/index.content
(filled with dummy content)
targetfolder/config.yml
(basic config setup - server: webrick, port: 3000)
targetfolder/operator/operator.rb
(define your operator methods in module UserOperator)
In the layout.html you use {title}, {content} and {date} which will then be populated with the values from each .content file Example:
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{title}</h1>
<div>
{date}
{content}
</div>
</body>
</html>
The Content files (.content) includes your content
[path][/path]
- this will be your access path to your blog entry
[title][/title]
- the title for your article
[date][/date]
- publishing date of your article
[content][/content]
- your content
For a root document (http://pathtoapp.tld/) path should be empty ([path]:[/path])
In version 0.1.2 operator handling is included. To use this new feature you have to create a operator directory in your rackblog folder. In this directory create your operators (.rb files) with following skeleton
module UserOperator
end
Your operators are normal ruby methods defined in this module. Available params are documents & html
Param documents: An Array with document objects. This Document objects has following attributes: path, title, html
Param html: The content of the file where the operator was included
module UserOperator
def show_nav
end
end
In your layout.html then
<div class="nav">
{% show_nav %}
</div>
Implement pygments without nokogiri html parser (maybe use oga as alternative - https://github.com/YorickPeterse/oga)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request