Giter Site home page Giter Site logo

spud_blog's Introduction

Spud Blog

Spud Blog is a Blog Engine designed to be robust, easy to use, and light weight.

NOTE: This project is still in its early infancy.

Release Notes

  • 0.8.15 - Increased Spam Protection and Akismet spam service support (Check further down in Readme for instructions)

Installation/Usage

  1. In your Gemfile add the following

     gem 'spud_core'
     gem 'spud_blog'
    
  2. Run bundle install

  3. Copy in database migrations to your new rails project

     bundle exec rake railties:install:migrations
     rake db:migrate
    
  4. run a rails server instance and point your browser to /spud/admin

Configuration

Spud Blog current accepts the following configuration options.

Spud::Blog.configure do |config|
  config.base_layout = 'blog'
  config.blog_enabled = true
  config.news_enabled = true
  config.blog_path = 'blog'
  config.news_path = 'news'
  config.posts_per_page = 5
  config.has_custom_fields = false
  config.custom_fields = []
  config.caching_enabled = true
  config.caching_expires_in = 1.hour
end

Customizing Views

A number of built-in views have been provided to help you get started with the frontend display. Customzing these views will require you to copy them into your local application, which can be accomplished by using the views generator.

rails generate spud:blog:views

NOTE: The built-in views are likely to undergo changes as features are added to the blogging engine. If a new version of Spud Blog does not play nicely with your customized views, try backing up your views to an alternate location and running the views generator again to see what has changed.

Javascript Driver

Spud Blog includes a small, unobtrusive javascript driver that adds functionality to the built-in views. Including the driver is optional, as all client-side views and controllers are designed to work whether you include it or not.

<%= javascript_include_tag 'spud/blog' %>

Custom Fields

You may find that your blog requires a field that isn't included in the default spud_post model. Adding custom fields is easy.

  1. Set has_custom_fields to true in your Spud Blog configuration
  2. Create a migration adding the necessary column(s) to your database
class AddCaptionToPosts < ActiveRecord::Migration
  def change
    add_column :spud_posts, :caption, :string
  end
end
  1. Add an array of the new custom fields to Spud::Blog.config.custom_fields in application.rb for strong parameter filtering.
Spud::Blog.configure do |config|
  config.custom_fields = [:caption]
end
  1. Save a view partial at app/views/spud/admin/posts/_custom_fields.html.erb with the desired inputs
<div class="control-group">
    <%= f.label :caption, 'Caption',:class => "control-label" %>
    <div class="controls">
        <%= f.text_field :caption %>
    </div>
</div>

Extending the Post Model

Rails engines allow you to extend or even completely override classes by adding them to your local application. Source files found in your local app's path will take precedence over those found within the Spud Blog gem. Lets say you wanted to extend the SpudPost model.

  1. Create a file at app/models/spud_post.rb

  2. Add the following code:

     # Use this helper method to pull in the SpudPost source code from the engine
     Spud::Blog::Engine.require_model('spud_post')
    
     # Add your own methods to SpudPost
     class SpudPost
         attr_accessible :caption
         def byline
             return "'#{self.title}' was posted by #{self.author.full_name} on #{self.display_date}"
         end
     end
    

Akismet Support

Spud Blog Engine now supports spam comment filtering using akismet. All you have to do is configure the rakismet gem and enable_rakismet in the spud_blog configuration. Add the following to your application.rb file

Spud::Blog.configure do |config|
    config.enable_rakismet = true
end
config.rakismet.key = "your key here"
config.rakismet.url = 'http://yourdomain.com/'

Also make sure to add the rakismet gem to your gemfile

    gem 'rakismet'

Testing

Spud uses RSpec for testing. Get the tests running with a few short commands:

  1. Create and migrate the databases:

     rake db:create
     rake db:migrate
    
  2. Load the schema in to the test database:

     rake app:db:test:prepare
    
  3. Run the tests with RSpec

     rspec spec
    

After the tests have completed the current code coverage stats is available by opening /coverage/index.html in a browser.

spud_blog's People

Contributors

davydotcom avatar gregawoods avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spud_blog's Issues

Rails 4 upgrade

The following things need implemented for rails4 ...

  • Strong Parameters
  • Unify admin controllers for news/blog
  • Rspec test upgrades
  • Unified Renderer platform for support for things like markdown and more
  • Fixes on scopes
  • Removal of attr_accessible

Comment management

There doesn't appear to be a way to remove comments from a blog post. How do I get rid of the spam? Oh, and... better comment spam protection is needed.

Merge sweepers

It may be advisable to merge all 3 of your sweepers into one like I did in spud cms. This will help keep the code are down in size if possible.

Rakismet Support

Use gem 'rakismet' to implement rakismet support. This gem should not be required, but when added automatically enabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.