Repository URL to install this package:
Version:
2.4.0 ▾
|
app |
config |
db |
lib |
README.md |
Rakefile |
News engine for the Neoteric Design CMS.
Neoteric CMS gems are served from a private host. Replace SECURE_GEMHOST
with the source address.
# Gemfile source SECURE_GEMHOST do gem 'articular', '~> 2.0.0' end
$ bundle install $ rails g articular:install -or- $ rails g articular:install MODEL_NAME (default is NewsPost) $ rake db:migrate
Out of the box, you'll get a NewsPost model and a corresponding controller
class NewsPost < Articular::Article end
Attribute/method | Description |
---|---|
title |
Article title |
excerpt |
Plaintext (or lightly styled) excerpt |
state |
'drafted' or 'published' state |
published_at |
Datetime of publishing, by default future articles are private |
meta_description |
For page's meta tags |
body |
Article body (when not using Blocks) |
------------------------ | -------------------------------------------- |
next |
Next published article, chronologically |
prev |
Previous published article, chronologically |
Scope/method | Description |
---|---|
newest_first |
Default scope published_at descending |
oldest_first |
published_at ascending |
published |
Not drafted, present |
drafted |
Drafted or future |
future |
Published after now |
present |
Published on or before now |
by_month(year, month) |
All posts with published_at in given month |
by_year(year) |
All posts with published_at in given year |
class AnyNameController < ApplicationController include Articular::Controller end
Articular will guess what class it's working with based on the controller's name, but this can be overridden. Most of the operations like generating the title and pagination have been broken down into small methods so they can be easily overriden. See lib/articular/controller.rb for what's under the hood.
In addition to these methods, feel free to replace the actions according to your own needs.
Because of the fancy date-based routes, Articular includes some url helpers for generating links to articles. It does the reflection on the article class and date for you and uses Rails' url_for
under the hood that should work in most instances. You can override the optional options hash if it doesn't.
article_path(news_post) #=> "/news/2016/04/cotton-eye-joe" article_url(blog_post) #=> "http://mydomain.com/blog/2016/10/31/legend-of-spooky-pete"
Ships with support for Neoteric Design Topical tagging engine.
class NewsPost < Articular::Article topical_on :news_topics end
To use a different tagging method, remove that reference from the model, and override the tagged
action in your controller.
Articular comes with (hopefully) everything you need to set up an admin interface. Articular can generate one for you when you're installing.
articular.js
and articular.scss
Articular.params
to the whitelist# app/assets/javascripts/active_admin.js.coffeescript # ... #= require articular # ...
// app/assets/stylesheets/active_admin.css.scss // ... @import 'articular'; // ...
# app/admin/news_posts.rb ActiveAdmin.register NewsPost do menu :priority => 2 actions :all, :except => :show config.sort_order = 'published_at DESC' permit_params Articular.params, news_topic_ids: [] filter :title filter :body filter :published_at scope :all scope :published form :partial => 'form' index do column :title column :state do |post| span post.state, :class => "state-label #{post.state}" end column :published_at actions end controller do def find_resource scoped_collection.friendly.find(params[:id]) #FriendlyId Find end end end
See also the default ActiveAdmin register template.
A RSpec linting module is available to double check functionality.
describe NewsPost do include Articular::SpecHelpers::Lint end