markdown_datafier 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -10
- data/lib/markdown_datafier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987596b618b015006f29436d463283d11a3f9397
|
4
|
+
data.tar.gz: 5c36e8e66fcadf5734258e98fd351c14fe450744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad7dfefc8bdfe769c038568d321a4dd00038c5a0fd75a54b9e21eb662b172f6b3022652a0734409c80d4a31e8fe577fc89dda23083e195f6cfe50ad5179247d7
|
7
|
+
data.tar.gz: a944a3af3307174cc90eab2608b1126ff3f382d70cd327c215fa77bcfc689f2ef5821632422145af9548d8bc309a5ce306032ddee9c0f3e71d21d8ce32557929
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MarkdownDatafier
|
2
2
|
|
3
|
-
MarkdownDatafier is a ruby gem which reads a structure of Markdown files, parses their metadata and outputs to a simple hash. It
|
3
|
+
MarkdownDatafier is a ruby gem which reads a structure of Markdown files, parses their metadata and outputs to a simple hash or array of hashes. It's framework agnostic, configurable to any content location, and is easy to plug into your own API endpoints or controller actions.
|
4
4
|
|
5
5
|
MarkdownDatafier was inspired by the NestaCMS framework. But instead of a self-contained CMS, I simply wanted to get data out of a Markdown file structure to be used however I like (direct into Mustache templates via server-side Sinarta or Rails; or via an API endpoint to a javascript framework, iOS/Android app, and so on).
|
6
6
|
|
@@ -14,15 +14,20 @@ Add this line to your application's Gemfile:
|
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
17
|
-
|
17
|
+
bundle install
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
|
21
|
+
gem install markdown_datafier
|
22
|
+
|
23
|
+
|
24
|
+
## Purpose
|
25
|
+
|
26
|
+
I've attempted to design this gem to be useful in a few different ways, depending on your needs. In each case, you create a server instance targeted at the content directory of your choosing. However, how you represent your content in Markdown and what you do with the resulting structured data is up to you. For instance, you can set it up so that each page of a website is represented by the structure of your Markdown files and subdirectories (look in /spec/fixtures/server_content/ for an example of this). Or, you could alternatively use each Markdown file to represent persistence of object data (look in /spec/fixtures/instances/ for an example of this), which could then be used to create objects on another class.
|
22
27
|
|
23
28
|
## Setup
|
24
29
|
|
25
|
-
Create
|
30
|
+
Create one (or many) Datafier objects by requiring and including MarkdownDatafier for your class:
|
26
31
|
|
27
32
|
require 'markdown_datafier'
|
28
33
|
class MyDatafier
|
@@ -30,10 +35,8 @@ Create an object, include MarkdownDatafier and set the absolute path to your Mar
|
|
30
35
|
end
|
31
36
|
|
32
37
|
## Usage
|
33
|
-
|
34
|
-
I've attempting to design this module to be useful in a few different ways, depending on your needs. In each case, you create a server instance targeted at the content directory of your choosing. However, how you design your application to both represent your content in Markdown and what you do with the resulting structured data is up to you. For instance, you can set it up so that each page of a website is represented by the structure of your Markdown files and subdirectories (look in /spec/fixtures/server_content/ for an example of this). Or, you could alternatively use each Markdown file to represent persistence of object data (look in /spec/fixtures/instances/ for an example of this), which could then be used to create objects on another class.
|
35
38
|
|
36
|
-
Set up an instance of your server, passing the
|
39
|
+
Set up an instance of your server, passing the path to your content directory as shown:
|
37
40
|
|
38
41
|
server = MyDatafier.new(content_path: "/path/to/content/directory")
|
39
42
|
|
@@ -59,7 +62,7 @@ Or a splash page like so:
|
|
59
62
|
|
60
63
|
content = server.splash_page
|
61
64
|
|
62
|
-
Both the home_page and
|
65
|
+
Both the home_page and splash_page methods work by the file naming convention on the root :content_path.
|
63
66
|
|
64
67
|
You can also grab a collection of indexes for the top level sections of your content
|
65
68
|
|
@@ -69,11 +72,11 @@ Or specify a sub level (for instance by using the "shortname" of previously retr
|
|
69
72
|
|
70
73
|
collection = server.indexes_for_sections("/section-two")
|
71
74
|
|
72
|
-
Take a look at the file structure in spec/fixtures/
|
75
|
+
Take a look at the file structure examples in spec/fixtures/ to see how the directory structure and meta data works. You can pass any fields in the meta data that you like. Many basic ones are assumed and set for you as well.
|
73
76
|
|
74
77
|
## Recommendation
|
75
78
|
|
76
|
-
This will
|
79
|
+
This will work just dandy running as it does in Ruby's ObjectSpace. However, the intention is that you would use Markdown files to manage your content and its structure, and either use Rake to generate actual HTML files or set up some sort of caching system (clearing and rewriting your cache when content is changed). There's no need to be doing all this parsing overhead with each request to your application.
|
77
80
|
|
78
81
|
## Contributing
|
79
82
|
|