Name: blogd
Owner: Elao
Description: null
Created: 2014-10-01 09:51:44.0
Updated: 2015-03-16 07:09:47.0
Pushed: 2014-12-20 10:53:30.0
Homepage: null
Size: 306
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Blogd allow you to retrieve blog's posts and meta from a folder, a git repository or a remote zip and expose them via an API. It's useful when you want to manage a collaborative blog with github for example. Blogd is maintained by http://www.elao.com and is use at http://www.elao.com/blog. The content repository of the blog is located at http://www.github.com/elao/tech-blog.
Add a config.js file (copy / past the config.js.dist for example). Or you can also define a blogd config key in your package.json file (or in ../../package.json file).
Example of config.js file
'use strict';
exports.port = process.env.PORT || 5555;
exports.host = '127.0.0.1';
exports.store = 'memory'; // or memory
exports.outputFolder = __dirname + "/content";
exports.backupFile = __dirname + "/current.json";
exports.assetsToCopy = [{
from: exports.outputFolder + "/posts/images/",
to: __dirname + "/public/images",
url: "/images/"
}];
exports.security = {
rules: {
guest: {},
admin: {}
},
basic: {
realm: 'Blogd Private Api',
user: 'admin',
password: 'private'
}
};
exports.source = {
type: 'zip',
url: 'https://github.com/Elao/tech-blog/archive/master.zip'
}
Available configuration options:
Method | Route | Params | Description |
---|---|---|---|
GET | /posts | limit The number of posts to retrieve offset The offset status Filter by post status | Retrieve list of blog's post ordered by publish date desc |
GET | /posts/:tag | tag: a tag limit The number of posts to retrieve offset The offset status Filter by post status | Retrive list of blog's post by tag |
GET | /post/:slug | slug: a post's slug | Retrieve a single post |
GET | /tags | **none** | Retrieve the list of available tags |
GET | /authors | **none** | Retrieve the list of authors |
GET | /authors/:slug | slug: slug or email of an author | Retrieve an author |
GET | /authors/:slug/posts | slug: slug or email of an author | Retrieve list of posts from given author |
GET | /status | **none** | Retrieve the content status (last update, number of tags, posts, authors, ...) |
GET | /refresh | **none** | Force the refresh of the data by retrieving the remote data from the source |
In your config, you can define mapped directories from your source, to a folder and an url. For example:
exports.assetsToCopy = [{
from: exports.outputFolder + "/posts/images/",
to: __dirname + "/public/images",
url: "/images/"
}];
Blogd will copy the content of /posts/images/ from your repository, to the Blogd local directory /public/images and then map the /public/images/ folder to the url /images/ For example, if you have a file /posts/images/myimage.png in your repository, you'll be able to access the file to http://localhost:5555/images/myimage.png
The content of the source must be structured this way (you can find an example at https://github.com/Elao/tech-blog)
Must be at the root of the repo and named users.json
Example of users.json file:
[{
"name": "Vincent",
"slug": "vincent",
"email": "vincent.bouzeran@elao.com"
},{
"name": "Guewen",
"slug": "guewen",
"email": "guewen.faivre@elao.com"
}]
Must be at the root of the repo and be named tags.json It contains the allowed tags used in posts. If a post use a tag not referenced in these file, the tag will be ignored. Properties label and slug on tag objets are mandatory, but you can add other metas and you'll get them back through the API.
Example of tags.json file:
[
{"label": "Symfony", "slug": "symfony"},
{"label": "HTML/CSS", "slug": "html-css"},
{"label": "Webdesign", "slug": "webdesign"},
{"label": "Framework", "slug": "framework"},
{"label": "Translation", "slug": "translation"},
{"label": "Form", "slug": "form"},
{"label": "Theming", "slug": "theming"},
{"label": "Linux", "slug": "linux"},
{"label": "Tips", "slug": "tips"},
{"label": "Talk", "slug": "talk"},
{"label": "PHP", "slug": "php"}
]
The post files must be placed in the /posts folder. Each post must have two files: a markdown file and a meta file.
For each post, you need to have 2 files in the /posts folder
The two files must have the same name except the extension.
Example:
If your post is named “mysuperblogpost”, you must have these two files in the /posts folder:
The post meta file contains information about the associated blog post.
The metas are like this:
Meta | Description |
---|---|
_slug_ \* | The post's slug (used to identify the post. Must be unique among all posts) |
_title_ \* | The post's title |
_tags_ | List of post's tag (must be reference by slug or label of tags contains in the tags's file) |
_status_ \* | The post's status ("published", "draft") |
_publish_by_ \* | The publisher of the post (must be the reference of a user contains in the users's file either by email or slug) |
_publish_at_ \* | A date (any format supported by Moment.js) |
_meta_title_ | The html meta title of the post |
_meta_description_ | The html meta description of the post |
* indicate required metas
Additional metas will be exposed by the blogd api.
Example of a post meta file:
"tags": ["Infra", "Proxmox", "Linux"],
"title": "Partitioning a proxmox server",
"slug": "partitioning-a-proxmox-server",
"status": "published",
"meta_category": "virtualisation",
"meta_title": "Partitioning a proxmox server",
"meta_description": "How to do it clean and effective",
"meta_language": "en",
"meta_keywords": ["Proxmox", "Infra", "Linux", "OVH"],
"thumbnail": "/blog/medias/thumbnails/proxmox.png",
"publish_by": "guewen-faivre",
"publish_at": "2014-11-13"