# GOV.UK Admin Template Styles, scripts and templates wrapped up in a gem for getting up and running with [Bootstrap](http://getbootstrap.com) based backend admin apps. This gem provides (via a Rails engine): * jQuery * Bootstrap 3 standard styles and javascript — including HTML5 and respond.js shims necessary for IE <= IE8 * An admin layout with header and footer * A [lightweight javascript framework](JAVASCRIPT.md) * Admin design patterns available from `/style-guide` (when routes are mounted) * [CSS helpers and SASS variables](CSS.md) for the admin theme * GOV.UK user friendly date formats * Google Analytics tracking code (Universal Analytics), using the "GOV.UK apps" profile [Apps using this gem](https://github.com/search?q=govuk_admin_template+user%3Aalphagov+filename%3AGemfile) include: * [Transition](https://github.com/alphagov/transition) * [Maslow](https://github.com/alphagov/maslow) * [Publisher](https://github.com/alphagov/publisher) * [Sign on](https://github.com/alphagov/signonotron2) * [Panopticon](https://github.com/alphagov/panopticon) * [Imminence](https://github.com/alphagov/imminence) * [Support](https://github.com/alphagov/support) * [Travel advice publisher](https://github.com/alphagov/travel-advice-publisher) * [Specialist publisher](https://github.com/alphagov/specialist-publisher) * [Search admin](https://github.com/alphagov/search-admin) ## Usage Firstly, include the gem in your Gemfile, pinned to the appropriate version and run ```bundle```: ```ruby gem 'govuk_admin_template', '1.0.0' ``` At the top of `application.scss` include the styles (this provides all the mixins and variables from the gem as well as from bootstrap — [bootstrap mixins](https://github.com/twbs/bootstrap-sass/blob/master/vendor/assets/stylesheets/bootstrap/_mixins.scss)): ```css @import 'govuk_admin_template'; ``` In `application.html.erb` after any content blocks you want to include, render the base template: ```erb <%= render :template => 'layouts/govuk_admin_template' %> ``` The [base template](app/views/layouts/govuk_admin_template.html.erb) includes: * Javascript and non-Javascript classes * Mobile friendly viewport * Bootstrap and jQuery javascript * IE HTML5 and respondjs shims, and HTML classes * header HTML * footer HTML You will also need to include your styles within the `
` of your HTML, do this using nested layouts: ```erb <% content_for :head do %> <%= stylesheet_link_tag "application", :media => "all" %> <% end %> ``` It is recommended that the style guide is also made available within your app at the route `/style-guide`. Add this to your `config/routes.rb` file: ```ruby mount GovukAdminTemplate::Engine, at: "/style-guide" ``` The gem source includes a [dummy app](spec/dummy) configured to behave like an app using the gem. If you have the gem checked out it can be run from the `spec\dummy` directory using `rails s`. For Javascript usage, available modules and writing modules, see the [Javascript guide](JAVASCRIPT.md). ### Content blocks The gem [uses nested layouts](http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts) for customisation. `content_for` | Description --------------- | ------------- `:app_title` | Name of your admin application `:app_home_path` | Path to the home page of your application, defaults to `root_path` `:content` | Main content `:head` | HTML to include in the `` of your application `:page_title` | Page title `:navbar_items` | A set of HTML list items (`