Project

blog_boi

0.0
No release in over 3 years
Low commit activity in last 3 years
Easily add blogging functionality to your rails project using BlogBoi.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 5.0.0.alpha1
~> 4.3, >= 4.3.3
~> 2.1, >= 2.1.0
~> 6.0, >= 6.0.0
~> 0.1.0
 Project Readme

By Charlie Reese at Clientelify

BlogBoi

BlogBoi is a rails gem / engine that provides out-of-the-box blogging functionality to your rails application.

It requires active_storage for photo upload / storage.

Installation

  1. Add this line to your application's Gemfile:
gem 'blog_boi', '~> 0'
  1. Add these lines to your config/application.rb file:
require "active_storage/engine" # If doesn't exist already

ActiveStorage::Engine.config
.active_storage
.content_types_to_serve_as_binary
.delete('image/svg+xml')
  1. And then execute:
$ bundle
$ rake active_storage:install `# If hasn't been run yet`
$ rake active_storage:update # if upgrading to rails 6
$ rails blog_boi:install:migrations `# not needed for dummy test application`
$ rails db:migrate

Your storage.yml file should now have this code:

test:
	service: Disk
	root: <%= Rails.root.join("tmp/storage") %>

local:
	service: Disk
	root: <%= Rails.root.join("storage") %>

Note: $ rails railties:install:migrations to copy all new migrations Note: to run migrations only for certain engine, rails db:migrate SCOPE=blog_boi. To revert all migrations from blog_boi engine you can run rails db:migrate SCOPE=blog_boi VERSION=0

  1. And then mount the engine in your app's config/routes.rb file:
mount BlogBoi::Engine, at: "/blog"
  1. Customize scss colour scheme by creating stylesheets/bootstrap_customizer.scss. See example in test/dummy/app/assets/stylesheets.

  2. And then add the engines configuration options in an initializer file (named blog_boi.rb):

BlogBoi.author_class = "User" # name of active record model containing authors with property called name (for author's name)

See lib/blog_boi.rb for all customization options (like setting your Blog's meta description / image).

  1. Finally, your parent application must define the method admin_signed_in?. If you are using Devise, this method may already exist. It should return true if the blog admin is signed in, and false if not. When it returns true, you may create, update, and destroy blog articles. It should be available in controllers and views; it should be defined in ApplicationController, and should be marked a helper method. E.g.
class ApplicationController < ActionController::Base

	helper_method :admin_signed_in?

	def admin_signed_in?
		...
	end

end

View partial hooks

List of view partial hooks that are rendered if they exist in parent application:

  • layouts/blog_boi/head_extension: (for adding html to head of blog_boi application layout in layouts/blog_boi/application)

Custom style / SCSS

To override SCSS bootstrap mixins / styles, add a file in parent application called blog_boi/bootstrap_overrides.scss.

Override the header or footer by placing your own files at views/layouts/_header or views/layouts/_footer

Further, you can add your own css classes / ids to your markup:

Running tests

  • Run all tests other than system: rake app:test
  • Run system tests: rake app:test:system
  • Run all tests: rake or rake test

Test coverage

Exists in coverage folder in root directory.

To view in a browser, execute from root directory: open coverage/index.html

License

The gem is currently available as open source software under the terms of the MIT License.

Contributing

If you'd like to make a fix / change, please create a pull request; when I have a moment, I'll have a look!

Updating gem version (for maintainers)

1. Update version

In lib/blog_boi/version.rb update version.

2. Build gem

gem build blog_boi.gemspec

3. Push gem

gem push blog_boi-X.X.X.gem (replace X's with version)

4. Tag GitHub

git add -A git commit -m "Msg" git push git tag -a vX.X.X -m "Msg" git push --tags