PigRider Blogs

Sign In
HTML CSS Javascript Ruby on Rails C++ Java Python SQL Git Linux Others All

Manual of the PigRider Global Layout Engine: PigRiderLayout

[Author: Dingyu]   [Thu, 2014-09-18, 16:08]   [2829 views]

Ruby on Rails

Six steps to hook PigRiderLayout into a new PigRider Application (click here to see how to make this PigRiderLayout engine): I have created GitHub repositories for pigrider.com website, please click here to see more details. 1. Edit Gemfile in the new application and add this line:
gem 'pigrider_layout', :path=>'../pigRiderLayout'
Then run bundle install to install this engine. 2. Edit config/routes.rb in the new application and add this line:
mount PigriderLayout::Engine, :at=>"/info"
Turning the routes file into this:
PigRiderExampleApp::Application.routes.draw do
  mount PigriderLayout::Engine, :at=>"/info"
  # Other route configurations here ...
3. Edit app/controllers/application_controller.rb in the new application and add this line:
layout '../pigrider_layout/main/globalLayout'
Turning the controller into this:
class ApplicationController < ActionController::Base
  # Other code here ...
  layout '../pigrider_layout/main/globalLayout'
4. Take a look in the directory app/views/pigrider_layout/main of the PigRiderLayout engine to see if there are any files that need to be overrided in the new application. If so, please create a new directory pigrider_layout/main in the new application folder app/views, and create files with the same name as ones you wish to override. Most of times, a new PigRider application should override these three files: _appHeadSetting.html.erb _headerApp.html.erb aboutUs.html.erb If meet any route problem, please consider to use main_app.example_path or pigrider_layout.example_path to specify the ambiguous route. 5. Take a look in the app/assets directory of the PigRiderLayout engine to see if there are any asset files that can be used in the new applicaiton. If so, please don't forget the namespace pigrider_layout. Examples to use these files: In a view file in the new application:
<%= stylesheet_link_tag "pigrider_layout/layout", :media=>"all" %>
In a CSS file int the new application:
@import "pigrider_layout/common";
6. There are some pre-written function modules in the PigRiderLayout engine. Use them in the new application if needed. Social Networks Sharing Module
This module is an addon to provide two ways, direct or indirect, to use Facebook like, Twitter following, LinkedIn sharing, and Google+ buttons. Add either of below codes in your view files to using these sharing buttons.
<%= render 'pigrider_layout/main/directSharing' %>
<!-- This will show sharing buttons directly. See example http://blogs.pigrider.com -->
<%= render 'pigrider_layout/main/indirectSharing' %>
<!-- This will show sharing buttons indirectly. See example http://tools.pigrider.com -->