{"id":23160979,"url":"https://github.com/steverandy/content_directory","last_synced_at":"2025-10-04T00:56:49.854Z","repository":{"id":7350208,"uuid":"8674184","full_name":"steverandy/content_directory","owner":"steverandy","description":"Content Directory is a lightweight replacement of Content Management System. It provides structure for text based content. It comes with a parser, which allows content entries to have metadata and rich formatting.","archived":false,"fork":false,"pushed_at":"2013-03-15T04:23:44.000Z","size":176,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T02:18:26.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steverandy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-09T18:29:39.000Z","updated_at":"2013-11-12T10:16:32.000Z","dependencies_parsed_at":"2022-08-29T15:21:39.488Z","dependency_job_id":null,"html_url":"https://github.com/steverandy/content_directory","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverandy%2Fcontent_directory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverandy%2Fcontent_directory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverandy%2Fcontent_directory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverandy%2Fcontent_directory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steverandy","download_url":"https://codeload.github.com/steverandy/content_directory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247236880,"owners_count":20906207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T23:12:58.866Z","updated_at":"2025-10-04T00:56:44.836Z","avatar_url":"https://github.com/steverandy.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Content Directory\n\nContent Directory is a lightweight replacement of Content Management System. It provides structure for text based content. It comes with a parser, which allows content entries to have metadata and rich formatting.\n\n## Structure\n\nContent Directory does not require a database. Instead, it uses file system. An entry is a file written in Markdown syntax (with one of the following extensions: .md, .markdown, .txt, .text). You can group related entries in a folder.\n\n    - content\n      - home\n        - main.md\n        - features\n          - collaboration.md\n          - manage.md\n      - posts\n        - a-new-blog.md\n        - sortable-stars.md\n  \n## Writing entries\n\nEntry uses Markdown syntax, but there is an additional rule that every entry must have a metadata declaration on the top. Metadata declaration block uses YAML syntax.\n\n    Title: Introduction\n    Date: 2013/03/10\n    Tags: [\"post\", \"short\"]\n\n    It was a bright cold day in April, and the clocks were striking\n    thirteen. Winston Smith, his chin nuzzled into his breast in an\n    effort to escape the vile wind, slipped quickly through the\n    glass doors of *Victory Mansions*, though not quickly enough to\n    prevent a swirl of gritty dust from entering along with him. \n\n    The hallway smelt of boiled cabbage and old rag mats. At one end\n    of it a coloured poster, too large for indoor display, had been\n    tacked to the wall. It depicted simply an **enormous** face,\n    more than a metre wide: the face of a man of about forty-five,\n    with a heavy black moustache and ruggedly handsome features.\n\n## Reading entries\n\nOnce you have written entries, you can use `ContentDirectory.find` to get the processed entries and render them into views.\n\n`ContentDirectory.find` returns a `Hash` of `ContentDirectory::Entry`. It accepts one argument, which is a path relative to `ContentDirectory.root`. If path is not specified, `ContentDirectory.find` will find all possible entries.\n\n    posts = ContentDirectory.find \"posts\"\n\nYou can use metadata to sort posts by date\n\n    posts = ContentDirectory.find(\"posts\").values\n    posts.sort_by! { |post| post.metadata[\"Date\"] }\n\nEntry has three important values: `metadata`, `text`, `html`. \n\n1. `metadata` is a `Hash` of parsed metadata block from entry file. \n2. `text` is a `String` of original entry text. \n3. `html` is a `String` of the result of original text after processed by Redcarpet Markdown parser.\n\nYou can you these three values to render entry to a view.\n\n    for post in posts\n      puts post.metadata[\"Title\"]\n      puts post.text\n      puts post.html\n    end\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem \"content_directory\"\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install content_directory\n\n## Configuration\n\nContentDirectory.root is default to `\"#{Rails.root}/content\"` when used in Rails. If you want to use other directory, you can easily change it in the initializer.\n\n    ContentDirectory.root = \"path/to/content\"\n\n## Use with Rails\n\nContent Directory is intended to be used in Rails to extract content from view templates. In this fashion, content can be easily reused and queried.\n\n1. Create `content` directory in Rails root path.\n2. Write entries in this directory. \n3. Use `ContentDirectory.find` in the controllers. \n4. Render entry `html` or `text` in the templates.\n\n## Test\n\n    rake test\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteverandy%2Fcontent_directory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteverandy%2Fcontent_directory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteverandy%2Fcontent_directory/lists"}