Giter Club home page Giter Club logo

contour's Introduction

Contour

Build Status Dependency Status Code Climate

Basic Rails framework files and assets for layout and authentication

Installation

Contour can be installed from rubygems.org using

gem install contour

Or update your Gemfile to include

gem 'contour'

Getting started

Make sure you have Rails 4.2.3

rails -v

rails new blank_rails_project

cd blank_rails_project

Modify Gemfile and add

gem 'contour', '~> 3.0.0'

Run Bundle install

bundle install

Install contour files

rails generate contour:install

Create a sample controller

rails generate controller welcome index --skip-stylesheets

Add the following line to your app/controllers/application_controller.rb

layout "contour/layouts/application"

Edit your app/assets/javascripts/application.js manifest to use Contour JavaScript (Replace jquery and jquery_ujs)

//= require contour

Add contour javascript if desired to the $(document).ready() function: app/controllers/my_app.coffee

@ready = () ->
  contourReady()
  ... # Your page-ready code

$(document).ready(ready)
$(document).on('page:load', ready) # For turbolinks

Edit your app/assets/stylesheets/application.css manifest to use Contour CSS (after self, before tree)

*= require contour

Make sure the devise line in config/routes.rb looks as follows

devise_for :users, controllers: { registrations: 'contour/registrations', sessions: 'contour/sessions', passwords: 'contour/passwords', confirmations: 'contour/confirmations', unlocks: 'contour/unlocks' }, path_names: { sign_up: 'register', sign_in: 'login' }

If there is a line that just says devise_for :users or a duplicate, REMOVE IT!

Create a root in your config/routes.rb

root to: 'welcome#index'

Add the following to the top of your app/controllers/welcome_controller.rb

before_action :authenticate_user!

Edit config/initializers/devise.rb to use :get for devise sign_out_via

# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :get

Start your server and navigate to http://localhost:3000/users/login

rails s

You can then sign in using your Google Account or by registering for an account at http://localhost:3000/users/register

Overwrite Default Rails Scaffolding (optional)

Add Kaminari gem to your Gemfile

gem 'kaminari', '~> 0.16.3'

Update your gems

bundle update

Create a new model using the Rails scaffold

rails g scaffold Item name:string description:text user_id:integer bought_date:date --no-stylesheets

Add a current scope and belongs_to relationship to app/models/item.rb

scope :current, -> { all }

belongs_to :user

Add a current scope and has_many relationship to app/models/user.rb along with name placeholder

scope :current, -> { all }

has_many :items

def name
  "User ##{self.id}"
end

Add a user resource to your config/routes.rb file

resources :users

NOTE: Adding the User controller is not shown, but could be created using rails g controller Users index show edit update destroy --no-stylesheets. Remember that the new and create actions are already defined and should be left commented out.

Migrate your database

bundle exec rake db:migrate

Update with the Contour scaffold

rails g contour:scaffold Item

When prompted to overwrite the existing files, type a for ALL.

NOTE: This will overwrite all the files generated by the rails scaffold command!

Go to http://localhost:3000/items to see the changes! Note, that the user_id selection now defaults to a drop down box!

Inspiration and Attribution

Contour is designed to rapidly prototype Rails applications with nice default styling and a solid authentication system. The Contour code base has been influenced by existing Rails Engines architectures that are listed below. Please check them out if you are interested in seeing how Contour is put together!

Devise

Devise is the highly configurable authentication gem that Contour utilizes.

Contour has adopted Devise's installation and configuration approach rails generate devise:install and config/intializers/devise.rb.

Twitter Bootstrap Rails

While Contour doesn't have an external dependency on the Twitter Bootstrap Rails gem, Contour does adopt the templating approach, rails generate contour:scaffold ModelName, used to overwrite the default scaffolding provided by Rails.

For those interested in having better control on modifying the Twitter Bootstrap Less file and CSS, I highly recommend taking a look at Twitter Bootstrap Rails!

Contributing to Contour

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright Creative Commons 3.0

Copyright (c) 2015 Remo Mueller. See LICENSE for further details.

contour's People

Contributors

pmanko avatar remomueller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

brownman90 pmanko

contour's Issues

Fix JS documentation

@ready -> ()
  contourReady()
  ... # Your page-ready code

$(document).ready(ready)
$(document).on('page:load', ready) # For turbolinks

Should probably be

@ready = () ->
  contourReady()
  ... # Your page-ready code

$(document).ready(ready)
$(document).on('page:load', ready) # For turbolinks

Glyphicon override is not sufficient

image

This error surfaces when using glyphicons.

I fixed the error by changing glyphicons-overrides.css.erb to:

@font-face {
  font-family: 'Glyphicons Halflings 2';
  src:url('bootstrap/glyphicons-halflings-regular<%= asset_path('bootstrap/glyphicons-halflings-regular.eot').split('glyphicons-halflings-regular').last %>');
  src:url('bootstrap/glyphicons-halflings-regular<%= asset_path('bootstrap/glyphicons-halflings-regular.eot').split('glyphicons-halflings-regular').last %>?#iefix') format('embedded-opentype'),
      url('bootstrap/glyphicons-halflings-regular<%= asset_path('bootstrap/glyphicons-halflings-regular.woff').split('glyphicons-halflings-regular').last %>') format('woff'),
      url('bootstrap/glyphicons-halflings-regular<%= asset_path('bootstrap/glyphicons-halflings-regular.ttf').split('glyphicons-halflings-regular').last %>') format('truetype'),
      url('bootstrap/glyphicons-halflings-regular<%= asset_path('bootstrap/glyphicons-halflings-regular.svg').split('glyphicons-halflings-regular').last %>#glyphicons_halflingsregular') format('svg');
}

.glyphicon {
    font-family: 'Glyphicons Halflings 2';
}

Add better default font

While the current font looks fine on a mac, the corresponding windows font looks less nice.

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.