0.0
No release in over 3 years
Low commit activity in last 3 years
Use the Rails model layer as a backend for static files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

ActiveCopy

ActiveCopy is a Rails model layer for reading from static page files. Inspired by Jekyll, it hacks ActionView to allow for storage of static page content inside app/views as YAML Front Matter/Markdown.

Although it's still very much a work in progress, ActiveCopy is being used in production on http://psychedeli.ca.

Build Status

Setup

Add to Gemfile:

gem 'active_copy'

And generate a model:

$ rails generate copy article

You'll get this as app/models/article.rb:

class Article < ActiveCopy::Base
  attr_accessible :title
end

You'll also see a generator pop up in lib/generators that corresponds to the name you gave the original generator. The copy generator actually "generates a generator" so that you can more easily generate your custom model records (files).

Usage

You can define articles in app/views/articles/content/your-article.md:

---
title: "The title of your article"
---

Hi I'm a static article.

Retrieve that article from a param in your route:

class ArticlesController < ApplicationController
  def show
    @article = Article.find params[:id]

    respond_with @article
  end
end

And show the article in your view:

#article
  %h1= @article.name
  .content= @article.content

Contributing

You can contribute by making a GitHub pull request. Please include tests with your feature/bug fix and an ample description as to why you're fixing the bug.

Roadmap

  • Generators