ro 1.4.6 → 4.2.0

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.
Files changed (66) hide show
  1. checksums.yaml +6 -14
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +43 -0
  4. data/LICENSE +1 -0
  5. data/README.md +120 -112
  6. data/README.md.erb +159 -0
  7. data/Rakefile +129 -78
  8. data/bin/ro +241 -68
  9. data/lib/ro/_lib.rb +95 -0
  10. data/lib/ro/asset.rb +45 -0
  11. data/lib/ro/collection/list.rb +23 -0
  12. data/lib/ro/collection.rb +168 -0
  13. data/lib/ro/config.rb +68 -0
  14. data/lib/ro/error.rb +8 -0
  15. data/lib/ro/klass.rb +25 -0
  16. data/lib/ro/methods.rb +238 -0
  17. data/lib/ro/model.rb +83 -114
  18. data/lib/ro/node.rb +177 -360
  19. data/lib/ro/pagination.rb +7 -4
  20. data/lib/ro/path.rb +225 -0
  21. data/lib/ro/root.rb +52 -31
  22. data/lib/ro/script/builder.rb +221 -0
  23. data/lib/ro/script/console.rb +47 -0
  24. data/lib/ro/script/server.rb +76 -0
  25. data/lib/ro/script.rb +189 -0
  26. data/lib/ro/slug.rb +19 -18
  27. data/lib/ro/template/rouge_formatter.rb +42 -0
  28. data/lib/ro/template.rb +104 -50
  29. data/lib/ro.rb +85 -317
  30. data/public/api/ro/index-1.json +147 -0
  31. data/public/api/ro/index.json +137 -0
  32. data/public/api/ro/posts/first_post/index.json +52 -0
  33. data/public/api/ro/posts/index-1.json +145 -0
  34. data/public/api/ro/posts/index.json +135 -0
  35. data/public/api/ro/posts/second_post/index.json +51 -0
  36. data/public/api/ro/posts/third_post/index.json +51 -0
  37. data/public/ro/posts/first_post/assets/foo/bar/baz.jpg +0 -0
  38. data/public/ro/posts/first_post/assets/foo.jpg +0 -0
  39. data/public/ro/posts/first_post/assets/src/foo/bar.rb +3 -0
  40. data/public/ro/posts/first_post/attributes.yml +2 -0
  41. data/public/ro/posts/first_post/blurb.erb.md +7 -0
  42. data/public/ro/posts/first_post/body.md +16 -0
  43. data/public/ro/posts/first_post/testing.txt +3 -0
  44. data/public/ro/posts/second_post/assets/foo/bar/baz.jpg +0 -0
  45. data/public/ro/posts/second_post/assets/foo.jpg +0 -0
  46. data/public/ro/posts/second_post/assets/src/foo/bar.rb +3 -0
  47. data/public/ro/posts/second_post/attributes.yml +2 -0
  48. data/public/ro/posts/second_post/blurb.erb.md +5 -0
  49. data/public/ro/posts/second_post/body.md +16 -0
  50. data/public/ro/posts/third_post/assets/foo/bar/baz.jpg +0 -0
  51. data/public/ro/posts/third_post/assets/foo.jpg +0 -0
  52. data/public/ro/posts/third_post/assets/src/foo/bar.rb +3 -0
  53. data/public/ro/posts/third_post/attributes.yml +2 -0
  54. data/public/ro/posts/third_post/blurb.erb.md +5 -0
  55. data/public/ro/posts/third_post/body.md +16 -0
  56. data/ro.gemspec +89 -29
  57. metadata +106 -90
  58. data/TODO.md +0 -50
  59. data/lib/ro/blankslate.rb +0 -7
  60. data/lib/ro/cache.rb +0 -26
  61. data/lib/ro/git.rb +0 -374
  62. data/lib/ro/initializers/env.rb +0 -5
  63. data/lib/ro/initializers/tilt.rb +0 -104
  64. data/lib/ro/lock.rb +0 -53
  65. data/lib/ro/node/list.rb +0 -142
  66. data/notes/ara.txt +0 -215
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NGU2NmU2NTUwNTgxZmM3OTUwYzYzNmFiZWQ3NzMyYzc3YmE0ODM2OQ==
5
- data.tar.gz: !binary |-
6
- YWM3ZjJhOWRmMWZiZWRlZmFmZWMzNTM1NzRlNzNkZTFkZmMxMzFmZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NmQ3Y2U2NTk3NWJhM2MyY2E0MmE2NWRkZWMwOGUwMGI3ZjMwZjgyNjI1ZjZk
10
- NjI1NTJmZWExMzQ5YmY4M2ExZDUwZTE2OTI5NWY3YjM4ODkxNDk1YTc3ZDYw
11
- NTZmODg5MjRlYTQzN2MxZGY1NGQxNDk3N2ZlODA5OWNiMGIxMjQ=
12
- data.tar.gz: !binary |-
13
- ODU5MWMwODIyNTM0NzdhMmFlMjczNjUyNWZjMTdmYzFkMmEwYmMwMWY0ZWUw
14
- NTQ5NTE3ZTU0NzUyZTcyM2QyNTFhOTUzYWNlMjhkMzE4Y2JhZjJlMWYwMDM5
15
- MGY4NDQxNzQ4NzcwMWIwZDA2MWE3NDFhYzgzOTIyNmJhNTBlMjM=
2
+ SHA256:
3
+ metadata.gz: 50e5d272b2bdbfe25f9ae109ed44568e71637820c4768ea772e757c7436c38cc
4
+ data.tar.gz: 84372b1f2cc28f316ed1eff63c0ce6ec4333f18a886a0cc38f4c86617baa0c0a
5
+ SHA512:
6
+ metadata.gz: e92b12b8067606b5b5ee11a3db65c926e492298aa3bed178459550d578a6b493762acbc3424fc0e2ac259d84d45cab1a69bc5e07e3550e58cbbdd14b18078c11
7
+ data.tar.gz: 7a587649abd8cb3a79e667d4767b33005a47a860983725546acdae8f97dfadaafe140f49fda93a12000097171ed4aba7fea5507467bd480b9b83496115aa3352
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ro (2.0.0)
5
+ ak47 (~> 0.2)
6
+ kramdown (~> 2.4, >= 2.4.0)
7
+ kramdown-parser-gfm (~> 1.1, >= 1.1.0)
8
+ map (~> 6.6, >= 6.6.0)
9
+ rouge (~> 4.1, >= 4.1.1)
10
+ webrick (~> 1.8.1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ ak47 (0.2.5)
16
+ guard (~> 0.10.0)
17
+ shell_tools (~> 0.1.0)
18
+ smart_colored
19
+ ffi (1.16.3)
20
+ guard (0.10.0)
21
+ ffi (>= 0.5.0)
22
+ thor (~> 0.14.6)
23
+ kramdown (2.4.0)
24
+ rexml
25
+ kramdown-parser-gfm (1.1.0)
26
+ kramdown (~> 2.0)
27
+ map (6.6.0)
28
+ rexml (3.2.6)
29
+ rouge (4.1.1)
30
+ shell_tools (0.1.2)
31
+ smart_colored (1.1.1)
32
+ thor (0.14.6)
33
+ webrick (1.8.1)
34
+
35
+ PLATFORMS
36
+ arm64-darwin-21
37
+ x86_64-linux
38
+
39
+ DEPENDENCIES
40
+ ro!
41
+
42
+ BUNDLED WITH
43
+ 2.4.22
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Ruby
data/README.md CHANGED
@@ -1,170 +1,178 @@
1
1
  NAME
2
- ----
2
+ ====
3
3
 
4
- ro
4
+ `ro`
5
5
 
6
+ INSTALL
7
+ =======
6
8
 
7
- TL;DR
8
- -----
9
-
10
- <pre>
11
-
12
- ro
13
- ├── people
14
- │   ├── ara
15
- │   │   ├── assets
16
- │   │   │   ├── ara-glacier.jpg
17
- │   │   │   └── source
18
- │   │   │   └── a.rb
19
- │   │   ├── attributes.yml
20
- │   │   └── bio.md.erb
21
- │   └── noah
22
- │   └── attributes.yml
23
- └── posts
24
- ├── foobar
25
- ├── hello-world
26
- │   ├── attributes.yml
27
- │   └── body.md
28
- └── second-awesome-post
29
- ├── attributes.yml
30
- └── body.md
9
+ as a gem
31
10
 
32
- </pre>
11
+ ```sh
12
+ ~> gem install ro
13
+ ```
33
14
 
34
15
 
35
- ```ruby
16
+ SYNOPSIS
17
+ ========
36
18
 
37
- ro
38
- #=> all the content nodes
19
+ keep all your content in git as god intended.
39
20
 
40
- ro.posts
41
- #=> all the post nodes
21
+ even images.
42
22
 
43
- ro.people
44
- #=> all people nodes
23
+ fuck wordpress.
45
24
 
46
- ro[:people]
47
- #=> same thing
25
+ # TL;DR;
48
26
 
49
- ro.people.ara
50
- #=> data for the person named 'ara'
27
+ `ro` is the world's tiniest, simplest, zero-config, and most bestest headless CMS.
51
28
 
52
- ro[:people][:ara]
53
- #=> same thing
29
+ it keeps your content in an on disk bundle that will make sense to an 11 year
54
30
 
55
- ro['people']['ara']
56
- #=> same thing
31
+ it depends on nothing but GitHub itself for the storage, management, and
32
+ delivery of rich web content and assets.
57
33
 
58
- ro.people.ara.first_name
59
- #=> give you *one* guess ;-) !
34
+ ## Storage
60
35
 
61
- ro.people.ara.url_for('ara-glacier.jpg')
62
- #=> external timestamped url for this asset
36
+ `ro` keeps your structured web content in a super sane structure, that keeps
37
+ assets close to its related content, allows for structured data to be kept
38
+ along side markdown/html content, and which supports source code as a first
39
+ class citizen.
63
40
 
64
- ro.people.ara.source('a.rb')
65
- #=> syntax highlighted source yo!
41
+ For example, given:
66
42
 
67
- ro.posts.find('second-awesome-post').body
68
- #=> html-z yo
43
+ ```sh
44
+ ~> tree ro/data
69
45
 
70
- ro.people.ara.related(:posts)
71
- #=> all related posts
46
+ # ro/data
47
+ # └── posts
48
+ # ├── first-post
49
+ # │   ├── attributes.yml
50
+ # │   └── body.md
51
+ # │   ├── blurb.erb.md
52
+ # │   ├── assets
53
+ # │   │   ├── foo.jpg
54
+ ```
72
55
 
73
- ro.people.ara.related(:featured_posts)
74
- #=> all featured posts
75
-
56
+ `ro` will provide an interface logically consistent with:
76
57
 
58
+ ```ruby
59
+ node.attributes #=> any/all the data loaded from 'attributes.yml'
60
+ node.attributes.body #=> an HTML representation of 'body.md'
61
+ node.attributes.blurb #=> an HTML representation of 'blurb.md'
62
+ node.attributes.assets #=> list of assets with url and path info
77
63
  ```
78
64
 
79
- TRY
80
- ---
65
+ To learn more, clone this repo, `bundle install`, and fire up a console to
66
+ check play with this idea:
81
67
 
82
- ```bash
68
+ eg: [given this node](https://github.com/ahoward/ro/tree/main/ro/data/posts/first-post)
83
69
 
84
- ~ > git clone https://github.com/ahoward/ro.git
85
- ~ > cd ro
86
- ~> ./bin/ro console
70
+ ```ruby
71
+ ~> ro console
87
72
 
73
+ ro[./ro/data]:001:0> ro.posts.first_post.title
74
+ => "First Post"
88
75
 
89
- a:~/git/ahoward/ro $ ./bin/ro console
90
- Ro(./ro):001:0> ro.people
91
- => [people/ara, people/noah]
76
+ ro[./ro/data]:002:0> ro.collections.posts.first_post.assets.first.url
77
+ => "/ro/posts/first-post/assets/foo.jpg"
92
78
 
93
- Ro(./ro):002:0> ro.people.ara
94
- => people/ara
79
+ ro[./ro/data]:003:0> ro.collections.posts.first_post.body.slice(0,42)
80
+ => "<div class='ro markdown'>\n <ul>\n <li>one"
81
+ ```
95
82
 
96
- Ro(./ro):003:0> ro.people.ara.first_name
97
- => "Ara"
98
83
 
99
- Ro(./ro):004:0> ro.people.ara.bio
100
- => "<ul>\n<li>one</li>\n<li>two</li>\n<li>three</li>\n</ul>\n\n<p>pretty syntax highlighting</p>\n<div class=\"highlight\"><pre> <span class=\"vi\">@a</span> <span class=\"o\">=</span> <span class=\"mi\">42</span>\n</pre></div>\n<p>Ara</p>\n\n<p>/ro/people/ara/assets/ara-glacier.jpg?_=1382999368</p>\n"
84
+ ## Management
101
85
 
102
- Ro(./ro):005:0> ro.people.ara.url_for('ara-glacier')
103
- => "/ro/people/ara/assets/ara-glacier.jpg?_=1382999368"
86
+ Managing `ro` is as simple as using the built-in GitHub Markdown editor. The
87
+ file system layout, which supports relative asset urls, means the built-in
88
+ editor preview renders just fine. Of course, you are free to manage content
89
+ programatically as well. Either way, updates to the the content will result
90
+ in an automated API build of a static API which is then deployed to GitHub
91
+ Pages.
104
92
 
105
- Ro(./ro):006:0> ro.people.ara.related
106
- => [posts/hello-world, posts/second-awesome-post]
93
+ This is made possible by certain design decisions `ro` has made, specifically
94
+ allowing assets/ to be stored and rendered relative to their parent content.
107
95
 
108
- Ro(./ro):007:0> ro.people.ara.related.posts
109
- => [posts/hello-world, posts/second-awesome-post]
96
+ Of course, you have all the power of `git` so other methods of managing the
97
+ content are available, programtic, locally in vs-code, etc. You have lots of
98
+ simply options, none of which require drivers or databases, and all of which
99
+ provide perfect history over your valuable web content and assets.
110
100
 
111
- Ro(./ro):008:0> ro.people.ara.related(:featured_posts)
112
- => [posts/second-awesome-post]
101
+ A word on managing assets, if you plan to have many large images, you probably
102
+ want to enable GitLFS on your content repository, `ro` plays perfectly with
103
+ it.
113
104
 
114
- ```
115
105
 
116
- DESCRIPTION
117
- -----------
106
+ ## Delivery
118
107
 
119
- ro is library for managing your site's content in git, as god intended.
108
+ Delivery of `ro` content, to remote clients, is via http+json. To output your
109
+ content as json, you simply need to run
120
110
 
121
- it features:
111
+ ```sh
112
+ ~> ro build
122
113
 
123
- - super fast loading via a robust caching/promise strategy
124
- - *all* teh templates supported via tilt (https://github.com/rtomayko/tilt)
125
- - the awesomest markdown ever, with syntax highlighting and even erb evaluation
126
- - an awesome command line tool for introspecting your data (./ro console)
127
- - data driven relationships
114
+ ro.build: public/ro -> public/api/ro
115
+ ro.build: public/api/ro/posts/first_post/index.json
116
+ ro.build: public/api/ro/posts/second_post/index.json
117
+ ro.build: public/api/ro/posts/third_post/index.json
118
+ ro.build: public/api/ro/posts/index/0.json
119
+ ro.build: public/api/ro/posts/index.json
120
+ ro.build: public/api/ro/index/0.json
121
+ ro.build: public/api/ro/index.json
122
+ ro.build: public/api/ro/index.html
123
+ ro.build: public/ro -> public/api/ro in 0.08s
128
124
 
125
+ ```
129
126
 
130
- ro is the *perfect* companion to a site built by a static site generator such
131
- as middleman (http://middlemanapp.com/). especially a middleman site with a
132
- companion rails' application doing concurrent modifications of the site's
133
- content... (ref: http://dojo4.com/blog/static-is-the-new-black) ;-)
127
+ During the build, assets are expanded to be the full URL of the final
128
+ deployment destination. This is done via the RO_URL environment variable, and
129
+ automatically with a pre-build GitHub Action that will deploy your content via
130
+ GitHub Pages. See
131
+ https://github.com/ahoward/ro/blob/main/.github/workflows/gh-pages.yml#L55 for
132
+ more details.
134
133
 
134
+ You can view sample output from this Action, deployed to GH Pages here: https://ahoward.github.io/ro
135
135
 
136
- INSTALL
137
- -------
138
136
 
139
- gem install ro
140
137
 
138
+ # USAGE
141
139
 
142
- CONFIG
143
- ------
140
+ #### WRITE-ME // #TODO
144
141
 
145
- if you are using the url methods you'll need to make sure your application can
146
- route to the assets. by default ro assumes that the urls it generates are
147
- routeable under '/ro' so it is up to you to make sure this works.
142
+ ## API // Javascript
148
143
 
149
- for a rails app this might mean writing a 'RoController' or, more simply, just
150
- putting your ro data in ./public/ro.
144
+ #### WRITE-ME // #TODO
151
145
 
152
- for a middleman app this might mean putting your ro data in ./source/ro.
146
+ ## CLI
153
147
 
154
- if you choose a non-standard approach you'll need to
148
+ #### WRITE-ME // #TODO
155
149
 
156
- ```
150
+ ## Programatic // Ruby
157
151
 
158
- Ro.route = '/my-custom-route'
152
+ #### WRITE-ME // #TODO
159
153
 
154
+ ## Via Repository
160
155
 
161
- ```
156
+ #### WRITE-ME // #TODO
162
157
 
163
- in all cases ro urls will be prefixed by the route, so be sure that this prefix
164
- is either automatically, or manually, exposed.
158
+ - note on http vs https
165
159
 
160
+ SAMPLES
161
+ =======
162
+ #### <========< [samples/a.rb](https://github.com/ahoward/ro/blob/main/samples/a.rb) >========>
163
+ ```sh
164
+ ~ > cat samples/a.rb
165
+ ```
166
+ ```ruby
167
+ require 'ro'
168
+
169
+ p 42
170
+ ```
166
171
 
167
- DOCS
168
- ----
172
+ ```sh
173
+ ~ > ruby samples/a.rb
174
+ ```
175
+ ```txt
176
+ 42
177
+ ```
169
178
 
170
- RTFC
data/README.md.erb ADDED
@@ -0,0 +1,159 @@
1
+ NAME
2
+ ====
3
+
4
+ `ro`
5
+
6
+ INSTALL
7
+ =======
8
+
9
+ as a gem
10
+
11
+ ```sh
12
+ ~> gem install ro
13
+ ```
14
+
15
+
16
+ SYNOPSIS
17
+ ========
18
+
19
+ keep all your content in git as god intended.
20
+
21
+ even images.
22
+
23
+ fuck wordpress.
24
+
25
+ # TL;DR;
26
+
27
+ `ro` is the world's tiniest, simplest, zero-config, and most bestest headless CMS.
28
+
29
+ it keeps your content in an on disk bundle that will make sense to an 11 year
30
+
31
+ it depends on nothing but GitHub itself for the storage, management, and
32
+ delivery of rich web content and assets.
33
+
34
+ ## Storage
35
+
36
+ `ro` keeps your structured web content in a super sane structure, that keeps
37
+ assets close to its related content, allows for structured data to be kept
38
+ along side markdown/html content, and which supports source code as a first
39
+ class citizen.
40
+
41
+ For example, given:
42
+
43
+ ```sh
44
+ ~> tree ro/data
45
+
46
+ # ro/data
47
+ # └── posts
48
+ # ├── first-post
49
+ # │   ├── attributes.yml
50
+ # │   └── body.md
51
+ # │   ├── blurb.erb.md
52
+ # │   ├── assets
53
+ # │   │   ├── foo.jpg
54
+ ```
55
+
56
+ `ro` will provide an interface logically consistent with:
57
+
58
+ ```ruby
59
+ node.attributes #=> any/all the data loaded from 'attributes.yml'
60
+ node.attributes.body #=> an HTML representation of 'body.md'
61
+ node.attributes.blurb #=> an HTML representation of 'blurb.md'
62
+ node.attributes.assets #=> list of assets with url and path info
63
+ ```
64
+
65
+ To learn more, clone this repo, `bundle install`, and fire up a console to
66
+ check play with this idea:
67
+
68
+ eg: [given this node](https://github.com/ahoward/ro/tree/main/ro/data/posts/first-post)
69
+
70
+ ```ruby
71
+ ~> ro console
72
+
73
+ ro[./ro/data]:001:0> ro.posts.first_post.title
74
+ => "First Post"
75
+
76
+ ro[./ro/data]:002:0> ro.collections.posts.first_post.assets.first.url
77
+ => "/ro/posts/first-post/assets/foo.jpg"
78
+
79
+ ro[./ro/data]:003:0> ro.collections.posts.first_post.body.slice(0,42)
80
+ => "<div class='ro markdown'>\n <ul>\n <li>one"
81
+ ```
82
+
83
+
84
+ ## Management
85
+
86
+ Managing `ro` is as simple as using the built-in GitHub Markdown editor. The
87
+ file system layout, which supports relative asset urls, means the built-in
88
+ editor preview renders just fine. Of course, you are free to manage content
89
+ programatically as well. Either way, updates to the the content will result
90
+ in an automated API build of a static API which is then deployed to GitHub
91
+ Pages.
92
+
93
+ This is made possible by certain design decisions `ro` has made, specifically
94
+ allowing assets/ to be stored and rendered relative to their parent content.
95
+
96
+ Of course, you have all the power of `git` so other methods of managing the
97
+ content are available, programtic, locally in vs-code, etc. You have lots of
98
+ simply options, none of which require drivers or databases, and all of which
99
+ provide perfect history over your valuable web content and assets.
100
+
101
+ A word on managing assets, if you plan to have many large images, you probably
102
+ want to enable GitLFS on your content repository, `ro` plays perfectly with
103
+ it.
104
+
105
+
106
+ ## Delivery
107
+
108
+ Delivery of `ro` content, to remote clients, is via http+json. To output your
109
+ content as json, you simply need to run
110
+
111
+ ```sh
112
+ ~> ro build
113
+
114
+ ro.build: public/ro -> public/api/ro
115
+ ro.build: public/api/ro/posts/first_post/index.json
116
+ ro.build: public/api/ro/posts/second_post/index.json
117
+ ro.build: public/api/ro/posts/third_post/index.json
118
+ ro.build: public/api/ro/posts/index/0.json
119
+ ro.build: public/api/ro/posts/index.json
120
+ ro.build: public/api/ro/index/0.json
121
+ ro.build: public/api/ro/index.json
122
+ ro.build: public/api/ro/index.html
123
+ ro.build: public/ro -> public/api/ro in 0.08s
124
+
125
+ ```
126
+
127
+ During the build, assets are expanded to be the full URL of the final
128
+ deployment destination. This is done via the RO_URL environment variable, and
129
+ automatically with a pre-build GitHub Action that will deploy your content via
130
+ GitHub Pages. See
131
+ https://github.com/ahoward/ro/blob/main/.github/workflows/gh-pages.yml#L55 for
132
+ more details.
133
+
134
+ You can view sample output from this Action, deployed to GH Pages here: https://ahoward.github.io/ro
135
+
136
+
137
+
138
+ # USAGE
139
+
140
+ #### WRITE-ME // #TODO
141
+
142
+ ## API // Javascript
143
+
144
+ #### WRITE-ME // #TODO
145
+
146
+ ## CLI
147
+
148
+ #### WRITE-ME // #TODO
149
+
150
+ ## Programatic // Ruby
151
+
152
+ #### WRITE-ME // #TODO
153
+
154
+ ## Via Repository
155
+
156
+ #### WRITE-ME // #TODO
157
+
158
+ - note on http vs https
159
+