filepress 0.2.0 → 0.2.1
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 +114 -9
- data/lib/filepress/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d19a795578233e2969fa1438a21c7614afab2650666a2a229338c2f322cccc0
|
4
|
+
data.tar.gz: cfcfbff322ea8909a384f580b6de6082f4a015808acb6d5e3f03a5bc02d17d54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a69c6dbb2a9491da1698d9d97ba37ebb4e3e6caceffa1b0d4e7c21d782c0d5d4111869c075fcddb339dd0df471db291a9f43f197cd11dbb9871042b013b5f14c
|
7
|
+
data.tar.gz: 9590840f2f26567dca12b04fc929c2273a5f21074b179abdf7fb0f96dc22de5720a9d2bb37c8eede06c516ebb7bfcf7b1c8e0ae7eacc6192b782a5a3c9406a4e
|
data/README.md
CHANGED
@@ -1,17 +1,122 @@
|
|
1
1
|
# Filepress
|
2
2
|
|
3
|
-
|
3
|
+
Filepress is a minimal Rails plugin that offers the best of both worlds for content management:
|
4
|
+
- Write and version control your content in Markdown (or a similar format)
|
5
|
+
- Sync it seamlessly to ActiveRecord models so you can harness the full power of a Rails backend.
|
4
6
|
|
5
|
-
|
7
|
+
Ideal for blogs, documentation, or any content-driven Rails app where you want the flexibility of flat files and the structure of a database.
|
6
8
|
|
7
|
-
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
1. Install the gem
|
12
|
+
|
13
|
+
Add it to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "filepress"
|
17
|
+
```
|
18
|
+
Then run:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
2. Create a model to represent your content
|
25
|
+
|
26
|
+
Be sure to include a field that can serve as a unique identifier (e.g. `slug`):
|
27
|
+
|
28
|
+
```bash
|
29
|
+
rails g model Post title:string slug:string body:text
|
30
|
+
```
|
31
|
+
|
32
|
+
3. Enable Filepress for your model
|
8
33
|
|
9
|
-
|
34
|
+
Use the `filepress` method in your model class:
|
10
35
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
36
|
+
```ruby
|
37
|
+
class Post < ApplicationRecord
|
38
|
+
filepress
|
39
|
+
end
|
40
|
+
```
|
16
41
|
|
42
|
+
4. Add some content
|
43
|
+
|
44
|
+
Create Markdown files in `app/content/posts`. Each file should include frontmatter:
|
45
|
+
|
46
|
+
```markdown
|
47
|
+
---
|
48
|
+
title: My First Post
|
49
|
+
slug: first
|
17
50
|
---
|
51
|
+
|
52
|
+
# Hello, this is my first post
|
53
|
+
```
|
54
|
+
|
55
|
+
5. Sync your content
|
56
|
+
|
57
|
+
Run the sync task to import your files into the database:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
bin/rails filepress:sync
|
61
|
+
```
|
62
|
+
|
63
|
+
That’s it! You’re now free to query your content via ActiveRecord like any other model. Filepress doesn't dictate how you render the body—use a Markdown parser like Kramdown, Redcarpet, or similar.
|
64
|
+
|
65
|
+
## How it works
|
66
|
+
|
67
|
+
Filepress reads your content files, extracts YAML frontmatter, and uses the values to populate or update model attributes. The rest of the file becomes the value of the body attribute (or another field, if configured).
|
68
|
+
|
69
|
+
## Configuration
|
70
|
+
|
71
|
+
You can customize how Filepress behaves by passing options to `filepress`:
|
72
|
+
|
73
|
+
### `from:` - Set a custom content directory
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
class Post
|
77
|
+
filepress from: "app/my_custom_content_folder"
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
### `glob:` - Use filetypes besides Markdown
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
class Post
|
85
|
+
filepress glob: "*.html"
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
### `key:` - Use a unique identifier other than `slug`
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
class Post
|
93
|
+
filepress key: :name
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
### `body:` - Set which attribute stores the main content
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
class Post
|
101
|
+
filepress body: :content
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
### `destroy_stale:` - Prevent deletion of records when files are removed
|
106
|
+
|
107
|
+
By default, Filepress deletes records when the corresponding file is removed. Disable this behavior with:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
class Post
|
111
|
+
filepress destroy_stale: false
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
## Why Filepress?
|
116
|
+
|
117
|
+
Filepress is for you if:
|
118
|
+
|
119
|
+
- You prefer writing content in files
|
120
|
+
- You want the convenience of version control for content
|
121
|
+
- And you still want powerful querying, associations, validations and all the other Rails goodness
|
122
|
+
|
data/lib/filepress/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filepress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Dawson
|
@@ -45,7 +45,7 @@ licenses:
|
|
45
45
|
metadata:
|
46
46
|
allowed_push_host: https://rubygems.org
|
47
47
|
homepage_uri: https://github.com/carldaws/filepress
|
48
|
-
source_code_uri: https://github.com/
|
48
|
+
source_code_uri: https://github.com/carldaws/filepress
|
49
49
|
rdoc_options: []
|
50
50
|
require_paths:
|
51
51
|
- lib
|