Angle Docs

AngleBootstrap 4 Admin Template + Ruby on Rails

Thank you for purchasing Angle - Bootstrap 4 Admin Template + Ruby on Rails.
If you have any question about this product and beyond the scope of this help file, please feel free to write us using the support button.


Thanks so much!

Introduction

This document aims to explain the best way to work with the product and its components.

It assumes a minimum knowledge of Ruby and Ruby on Rails framework.

- All the best and enjoy coding.

Getting started tips

  • Do not start from scratch, use an existing asset and modify it to learn how it works.
  • Explore the sources for ideas and sample code.
  • Use Firebug or Chrome Developer Tools to find bugs on your website. Using one of those tools will help you to save time analyzing the site and finding elements structure, like classes, id or tags
    • Quick tip: open your site with Chrome, press F12 and go to console tab, reload your page and if something goes wrong you will see your page errors in red text.
  • In case of errors, someone might have seen it too, you can try a Google search for a quick fix.

Technologies used

This template is based on the following technologies. Follow the links for each one of them in order to get more information:

  • The project is based on Bootstrap 4

  • Language used: JavaScript, SCSS and raw HTML (ERB)

  • NPM dependency manager

Structure

Before starting to customize the template, here is the project files organization structure:

+---app
|   +---assets
|   |   +---api
|   |   +---config
|   |   +---i18n
|   |   +---images
|   |   +---javascripts
|   |   |   +---angle
|   |   |       +---custom
|   |   |       +---modules
|   |   |           +---charts
|   |   |           +---common
|   |   |           +---elements
|   |   |           +---extras
|   |   |           +---forms
|   |   |           +---maps
|   |   |           +---pages
|   |   |           +---tables
|   |   +---stylesheets
|   |       +---angle
|   |           +---app
|   |           |   +---charts
|   |           |   +---common
|   |           |   +---elements
|   |           |   +---extras
|   |           |   +---forms
|   |           |   +---layout
|   |           |   +---maps
|   |           |   +---tables
|   |           +---bootstrap
|   |           +---themes
|   +---channels
|   +---controllers
|   +---helpers
|   +---jobs
|   +---mailers
|   +---models
|   +---views
|       +---blog
|       +---charts
|       +---dashboard
|       +---ecommerce
|       +---elements
|       +---extras
|       +---forms
|       +---forum
|       +---layouts
|       |   +---partials
|       +---maps
|       +---multilevel
|       +---pages
|       +---tables
|       +---widgets
+---bin
+---config
+---db
+---lib
+---log
+---node_modules
+---public
+---test
+---vendor
    +---assets
        +---images
        |   +---bootstrap-colorpicker
        +---javascripts
        +---stylesheets

Build

To run this version you need to have installed Ruby and Ruby on Rails framework.

You will need also a Nodejs enviroment.

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

Installing tools

The following steps are intended to be an orientation guide, if you are not experienced with this you will need to learn more about it from Google :)

Starting the app

This project it ready to run on a local machine.

Once you have Ruby and Ruby on Rails installed:

1- Open a terminal and go to the root folder of the project

2- Run the command bundle install to install necessary gems

3- Run npm install to install node dependencies

4- Run the command rails server

5- A new server will start listening at http://localhost:3000 to show your app.

Usage

Layout

The theme uses a main layout for the admin pages and another layout for "external" pages

app/views/layouts/application.html.erb

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
   <meta name="description" content="Bootstrap Admin App + Ruby on Rails">
   <meta name="keywords" content="app, responsive, jquery, bootstrap, dashboard, admin">
   <title>Angle - Bootstrap Admin Template</title>
   <!-- =============== VENDOR STYLES ===============-->
   <%= stylesheet_link_tag 'base' %>
   <!-- =============== VIEW VENDOR STYLES ===============-->
   <%= stylesheet_link_tag params[:controller] %>
   <%= yield :vendor_css_area %>
   <!-- =============== APP STYLES ===============-->
   <%= stylesheet_link_tag 'application', media: 'all', id: "maincss" %>
   <%= csrf_meta_tags %>
</head>

<body>
   <div class="wrapper">
      <!-- top navbar-->
      <header class="topnavbar-wrapper">
         <%= render partial: "layouts/partials/topnavbar" %>
      </header>
      <!-- sidebar-->
      <aside class="aside-container">
         <%= render partial: "layouts/partials/sidebar" %>
      </aside>
      <!-- offsidebar-->
      <aside class="offsidebar d-none">
         <%= render partial: "layouts/partials/offsidebar" %>
      </aside>
      <!-- Main section-->
      <section class="section-container">
         <!-- Page content-->
         <div class="content-wrapper">
            <%= yield %>
         </div>
      </section>
      <!-- Page footer-->
      <footer class="footer-container">
         <%= render partial: "layouts/partials/footer" %>
      </footer>
   </div>
   <!-- =============== VENDOR SCRIPTS ===============-->
   <%= javascript_include_tag 'base' %>
   <!-- =============== VIEW VENDOR SCRIPTS ===============-->
   <%= javascript_include_tag params[:controller] %>
   <%= yield :vendor_js_area %>
   <!-- =============== APP SCRIPTS ===============-->
   <%= javascript_include_tag 'application' %>

   <%= yield :body_area %>

</body>

</html>

app/views/layouts/pages.html.erb

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
   <meta name="description" content="Bootstrap Admin App + Ruby on Rails">
   <meta name="keywords" content="app, responsive, jquery, bootstrap, dashboard, admin">
   <title>Angle - Bootstrap Admin Template</title>
   <!-- =============== VENDOR STYLES ===============-->
   <%= stylesheet_link_tag 'base' %>
   <!-- =============== VIEW VENDOR STYLES ===============-->
   <%= stylesheet_link_tag params[:controller] %>
   <!-- =============== APP STYLES ===============-->
   <%= stylesheet_link_tag 'application', media: 'all', id: "maincss" %>

   <%= csrf_meta_tags %>
</head>

<body>
   <div class="wrapper">
      <%= yield %>
   </div>
   <div class="p-lg text-center">
      <span>&copy;</span>
      <span>2016</span>
      <span>-</span>
      <span>Angle</span>
      <br>
      <span>Bootstrap Admin Template</span>
   </div>
   <!-- =============== VENDOR SCRIPTS ===============-->
   <%= javascript_include_tag 'base' %>
   <!-- =============== VIEW VENDOR SCRIPTS ===============-->
   <%= javascript_include_tag params[:controller] %>
   <!-- =============== APP SCRIPTS ===============-->
   <%= javascript_include_tag 'application' %>
</body>

</html>

Stylesheets and Scripts

Here is how we manage assets per controller inclusion. Following what is defined in the main layout file application.html.erb

This requires the file base.css.scss that contains vendor styles necessary accros all application

<%= stylesheet_link_tag 'base' %>

This requires the file [controller_name].css.scss that contains vendor styles for such controller

<%= stylesheet_link_tag params[:controller] %>

This requires the file application.css.scss that contains the application styles

<%= stylesheet_link_tag 'application', media: 'all', id: "maincss" %>

This requires the file base.js that contains vendor scripts necessary across the application

<%= javascript_include_tag 'base' %>

This requires the file [controller_name].js that contains vendor scripts for such controller

<%= javascript_include_tag params[:controller] %>

This requires the file application.js that contains the application scripts

<%= javascript_include_tag 'application' %>

SASS

This projects also implements a SASS version (scss) of the theme.

All files are located under the folder /app/assets/stylesheets/angle/

It will compile the app styles with Bootstrap integrated. Remember that the less you change bootstrap, the easier will be to update it later.

One line about coffee

We don't use coffee scripts but this application is ready to use so you can create .coffee assets and they will compiled automatically.

New vendor assets

To add new third party assets, you can install using npm and the reference in the assets folder

  1. npm install something -S

    • Flag "-S" is to save the dependency in package.json
  2. Edit assets and add the paths of files you want to use

    Note that you don't need to specify the node_modules folder

    // app/assets/javascripts/controller_name.js
    //= require something/some/file.js
    // app/assets/stylesheets/controller_name.css.scss
    //= something/some/file.css

    The "controller_name" name used corresponds to the controller associated so the assets are loaded when the route associated with such controller is accessed.

  3. Finally, add the new assets in the list of precompile assets in config/application.rb

    config.assets.precompile += [
        ...
        'controller.js',
        'controller.css'
    ]

Modernizr

Modernizr build is generated after the command npm install ends. Specifically, using the postinstall script in package.json which at the same time executes the "modernizr" scripts responsible for generating the file modernizr.custom.js under folder vendor/assets/javascripts/modernizr.js The configuration of the Modernizr build can be found in file modernizr-config.json

jQuery and Wrapper script

Starting from version 4.1, this template doesn't need jQuery as a mandatory dependency for core files, this means it is only required when using jQuery based plugins for some features included.
Seed project versions no more include jQuery by default..

The wrapper.js (~ 7k minified) is a new script introduced to emulate some specific jQuery functions used in the template. This made possible to significantly cut the refactoring changes in the code, keeping it readable in a jQuery way and avoiding extra bytes, mainly when loops are repeatedly used to work with multiple elements.

Important The Wrapper script is NOT a replacement for jQuery. All methods were designed for an adequate and specific use and they don't do a deep validation on the arguments provided. It's suggested NOT to use this library extensively. Instead, use pure JS or you might even need jQuery.

Heroku

To deploy the project to Heroku you need an account first. Go here a create one heroku.com

Heroku explains very well the necessary steps to deploy a Ruby application here

In short,

1- Download and install the Heroku Toolbelt for your platform

2- Open a terminal and go to the root folder of the project

3- Edit the file Gemfile to enable postgresql like follows

# HEROKU doesn't support sqlite3.
# Comment this gem
# gem 'sqlite3'
# and uncomment the following
gem 'pg'
gem 'thin'

4- Install bundle packages

bundle install

5- Init a new GIT repository

git init

6- Log in to Heroku with your creadentials

heroku login

7- Create your Heroku application

heroku create myAppName

8- Add and commit source files with the following commands

git add .
git commit -m "Initialize repository"

9- Add build packs

heroku buildpacks:clear
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/ruby --index 2

10- Push changes to Heroku

git push heroku master

Done

If everything goes fine, you can run heroku open and the application will start in your favourite browser