Skip to content

Instantly share code, notes, and snippets.

@ahnbizcad
Last active August 29, 2015 14:10
Show Gist options
  • Save ahnbizcad/5f3f06cfd740df3ca31c to your computer and use it in GitHub Desktop.
Save ahnbizcad/5f3f06cfd740df3ca31c to your computer and use it in GitHub Desktop.
Rails App Default Modifications
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
# Ignore application secret keys (Figaro).
/config/application.yml
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//JQUERY
//
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
//
//PLUGINS
//
//= require bootstrap
//
// require (pseudo manifest name)
//
//
//TREE SUBSTITUTE
//
//
//
//TURBOLINKS
//
//= require turbolinks
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*/
/* */
/* RESET */
/* */
@import "custom/reset";
/* */
/* FRAMEWORKS */
/* */
/*@import "bootstrap-sprockets";*/
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
/* */
/* BLANKET STYLES */
/* */
@import "custom/variables";
@import "custom/bootstrap_override";
@import "custom/custom";
@import "custom/responsive";
/* */
/* Plugin-Specific Styles */
/* */
/* */
/* TREE SUBSTITUTE */
/* */
pre {
display: block;
outline:0;
margin: 0;
padding:0;
font-size:100%;
vertical-align:baseline;
line-height: 1.25em;
word-break: break-all;
word-wrap: break-word;
color: #000;
background:transparent;
border:0;
border-radius:0;
}
/*--------------------------
bootstrap adjust
--------------------------*/
/*--------------------------
Reusable OO
--------------------------*/
/*--------------------------
By Item
--------------------------*/
app/assets/stylesheets/custom/reset.css.scss
/**
* html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/)
* Richard Clark (http://richclarkdesign.com)
* http://cssreset.com
*/
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, li,a
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
iframe{
vertical-align: bottom;
}
body {
line-height:1;
}
article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section {
display:block;
}
nav ul {
list-style:none;
}
blockquote, q {
quotes:none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content:'';
content:none;
}
a {
margin:0;
padding:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
/* change colours to suit your needs */
ins {
background-color:#ff9;
color:#000;
text-decoration:none;
}
/* change colours to suit your needs */
mark {
background-color:#ff9;
color:#000;
font-style:italic;
font-weight:bold;
}
del {
text-decoration: line-through;
}
abbr[title], dfn[title] {
border-bottom:1px dotted;
cursor:help;
}
table {
border-collapse:collapse;
border-spacing:0;
}
/* change border colour to suit your needs */
hr {
display:block;
height:1px;
border:0;
border-top:1px solid #cccccc;
margin:1em 0;
padding:0;
}
input, select {
vertical-align:middle;
}
/**************************
RESPONSIVE CUTOFF WIDTHS
**************************/
/*----------------------------------------
ONLY xs devices (phones, 1px to 767px) (doesn't cascade)
----------------------------------------*/
/*@media only screen and (max-width: $screen-xs-max) {
}*/
/*--------------------------------------------------------------------------------*/
/*----------------------------------------
xs is default. Smaller sizes cascade to larger sizes. Flow structure.
----------------------------------------*/
/*----------------------------------------
sm devices (tablets, 748px and up)
----------------------------------------*/
@media only screen and (min-width: $screen-sm){
}
/*----------------------------------------
md devices (desktops, 992px and up)
----------------------------------------*/
@media only screen and (min-width: $screen-md){
}
/*----------------------------------------
lg devices (large desktops, 1200px and up)
----------------------------------------*/
@media only screen and (min-width: $screen-lg){
}
/**************************
GENERAL VARIABLES
**************************/
/*----------
Mixins - Dimensions
----------*/
/*
Responsive widths
*/
/*----------
Mixins - Positioning
----------*/
/*----------
Mixins - Colors, Styling
----------*/
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
before_action :configure_permitted_parameters, if: :devise_controller?
protected
# Devise strong parameters
def configure_permitted_parameters
#devise_parameter_sanitizer.for(:sign_up) << :username
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password) }
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :password_confirmation, :current_password) }
end
def currently_admin?
if user_signed_in?
current_user.admin? ? true : false
else
false
end
end
helper_method :currently_admin?
def authorize_admin
redirect_to root_path, alert: 'Access Denied' unless current_user.admin?
end
helper_method :authorize_admin
## 1) Install Gems
bundle
## 3) gem generator commands
#https://github.com/laserlemon/figaro
figaro install
#Do database yml, application.yml
#https://github.com/plataformatec/devise
rails generate devise:install
#https://github.com/plataformatec/simple_form
# Do simpleform between Devise commands.
rails generate simple_form:install --bootstrap
rails generate devise User
rails generate devise:views
## 3) Convert HTML files to Haml to Slim
# Do this after generating Devise views.
# Convert from erb to Haml
find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \
bash
# Convert from Haml to Slim
find . -name '*haml' | \
xargs ruby -e 'ARGV.each { |i| puts "haml2slim #{i} #{i.sub(/haml$/,"slim")}"}' | \
bash
# Delete erb files. Find regex to not delete any existing js.erb files.
find . -name '*erb' | xargs rm -rf ARGV
# Delete haml files.
find . -name '*haml' | xargs rm -rf ARGV
## 4)
#https://github.com/amatsuda/kaminari
figaro heroku:set -e production # To push keys to production
# Add application configuration variables here, as shown below.
#
# PUSHER_APP_ID: "lorem ipsum"
# PUSHER_KEY: lorem ipsum
# PUSHER_SECRET: lorem ipsum
#
# STRIPE_API_KEY: lorem ipsum
# STRIPE_PUBLIC_KEY: lorem ipsum
# app key For production
production:
SECRET_KEY_BASE: 'lorem ipsum'
DATABASE_USERNAME_PRODUCTION: 'lorem ipsum'
DATABASE_PASSWORD_PRODUCTION: 'lorem ipsum'
DEVISE_SECRET_KEY: 'lorem ipsum'
# For Twitter
# aka "API key" on dev.twitter
TWITTER_CONSUMER_KEY: 'lorem ipsum'
# aka "API secret" on dev.twitter
TWITTER_CONSUMER_SECRET: 'lorem ipsum'
# Keys to grant access to post on behalf of THE APP's twitter account.
TWITTER_YOUR_ACCESS_TOKEN: 'lorem ipsum'
TWITTER_YOUR_ACCESS_SECRET: 'lorem ipsum'
FACEBOOK_APP_ID: 'lorem ipsum'
FACEBOOK_APP_SECRET: 'lorem ipsum'
default: &default
adapter: postgresql
pool: 5
timeout: 5000
encoding: UTF8
development:
<<: *default
database: appname_development
host: localhost
username: postgres
password: postgres
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: appname_test
host: localhost
username: postgres
password: postgres
production:
<<: *default
database: appname_production
host: productionappname.com
username: postgres
password:
# Devise
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } #config/environments/development.rb
# Manifest files
# Not technically manifests
#Rails.application.config.assets.precompile += ['bookshelf.js', 'bookshelf.css']
# Images
Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/
# Fonts
Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
# Omniauth providers.
config.omniauth :github, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET']#, scope: 'user,public_repo'
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
config.wrappers :default, class: :input,
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
# You can make any of these extensions optional by
# renaming `b.use` to `b.optional`.
# Determines whether to use HTML5 (:email, :url, ...)
# and required attributes
b.use :html5
# Calculates placeholders automatically from I18n
# You can also pass a string as f.input placeholder: "Placeholder"
b.use :placeholder
## Optional extensions
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
# to the input. If so, they will retrieve the values from the model
# if any exists. If you want to enable the lookup for any of those
# extensions by default, you can change `b.optional` to `b.use`.
# Calculates maxlength from length validations for string inputs
b.optional :maxlength
# Calculates pattern from format validations for string inputs
b.optional :pattern
# Calculates min and max from length validations for numeric inputs
b.optional :min_max
# Calculates readonly automatically from readonly attributes
b.optional :readonly
## Inputs
b.use :label_input
b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
## full_messages_for
# If you want to display the full error message for the attribute, you can
# use the component :full_error, like:
#
# b.use :full_error, wrap_with: { tag: :span, class: :error }
end
# The default wrapper to be used by the FormBuilder.
config.default_wrapper = :default
# Define the way to render check boxes / radio buttons with labels.
# Defaults to :nested for bootstrap config.
# inline: input + label
# nested: label > input
config.boolean_style = :nested
# Default class for buttons
config.button_class = 'btn'
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
# Use :to_sentence to list all errors for each field.
# config.error_method = :first
# Default tag used for error notification helper.
config.error_notification_tag = :div
# CSS class to add for error notification helper.
config.error_notification_class = 'error_notification'
# ID to add for error notification helper.
# config.error_notification_id = nil
# Series of attempts to detect a default label method for collection.
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
# Series of attempts to detect a default value method for collection.
# config.collection_value_methods = [ :id, :to_s ]
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
# config.collection_wrapper_tag = nil
# You can define the class to use on all collection wrappers. Defaulting to none.
# config.collection_wrapper_class = nil
# You can wrap each item in a collection of radio/check boxes with a tag,
# defaulting to :span. Please note that when using :boolean_style = :nested,
# SimpleForm will force this option to be a label.
# config.item_wrapper_tag = :span
# You can define a class to use in all item wrappers. Defaulting to none.
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form
# You can define which elements should obtain additional classes
# config.generate_additional_classes_for = [:wrapper, :label, :input]
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
# These validations are enabled in SimpleForm's internal config but disabled by default
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
config.browser_validations = false
# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name
# matches the regexp as value.
# config.input_mappings = { /count/ => :integer }
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
# config.wrapper_mappings = { string: :prepend }
# Default priority for time_zone inputs.
# config.time_zone_priority = nil
# Default priority for country inputs.
# config.country_priority = nil
# When false, do not use translations for labels.
# config.translate_labels = true
# Automatically discover new inputs in Rails' autoload path.
# config.inputs_discovery = true
# Cache SimpleForm inputs discovery
# config.cache_discovery = !Rails.env.development?
# Default class for inputs
# config.input_class = nil
# Define the default class of the input wrapper of the boolean input.
config.boolean_label_class = 'checkbox'
# Defines if the default input wrapper class should be included in radio
# collection wrappers.
# config.include_default_input_wrapper_class = true
# Defines which i18n scope will be used in Simple Form.
# config.i18n_scope = 'simple_form'
end
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label, class: 'control-label'
b.wrapper tag: 'div' do |ba|
ba.use :input, class: 'form-control'
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label, class: 'control-label'
b.wrapper tag: 'div' do |ba|
ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.wrapper tag: 'div', class: 'checkbox' do |ba|
ba.use :label_input
end
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label_input
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label, class: 'col-sm-3 control-label'
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input, class: 'form-control'
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label, class: 'col-sm-3 control-label'
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
ba.use :label_input, class: 'col-sm-9'
end
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label, class: 'col-sm-3 control-label'
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
# Wrappers for forms and inputs using the Bootstrap toolkit.
# Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
config.default_wrapper = :vertical_form
end
resources :users, only: [:index, :show, :edit, :update]
devise_for :users, :path => '',
:path_names => { :sign_in => "login",
:sign_out => "logout",
:sign_up => "signup",
:account_update => "account" },
:controllers => { omniauth_callbacks: "authentications",
registrations: "registrations" }
source 'https://rubygems.org'
#ruby '2.0.0'
gem 'rails'
gem 'pg', '0.17.1'
# gem 'mysql2'
# Rails
gem 'jbuilder', '~> 2.0'
gem 'sprockets-rails', :require => 'sprockets/railtie'
# Postprocessing
gem 'autoprefixer-rails'
gem 'uglifier', '>= 1.3.0'
# HTML
gem 'html2haml' # Used for converting existing files (possible to generate in slim to begin with?)
gem 'haml2slim' # Used for converting existing files (possible to generate in slim to begin with?)
gem 'slim-rails'
# CSS
gem 'stylus'
#gem 'sass-rails', '~> 4.0.3'
#gem 'bootstrap-sass', '~> 3.2.0'
# JS
gem 'opal'
#gem 'typescript'
#gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
#gem 'angular-rails'
# Turbolinks
#gem 'turbolinks'
#gem 'jquery-turbolinks', '~>2.0.2'
# Rails
gem 'jbuilder', '~> 2.0'
gem 'sprockets-rails', :require => 'sprockets/railtie'
group :doc do
gem 'sdoc', '~> 0.4.0'
end
# Core
gem 'figaro', '~> 0.7.0'
gem 'simple_form', '~> 3.1.0.rc1'
# Parsing
#gem 'compass'
gem 'nokogiri' #html, xml, sax, reader and css parser # Convert HTML to Haml or Slim # Replaces hpricot
# Images
#gem 'filepicker-rails'
#gem 'carrierwave-rails'
#gem 'mini_magick'
#gem 'image_size', '~> 1.3.1'
#gem 'fastimage', '~> 1.6.4'
# Font/Markup
gem 'font-awesome-sass', '~> 4.2.0'
gem 'asciidoctor'
gem 'coderay', '~> 1.1.0'
# Authentication
gem 'devise'
gem 'omniauth'
gem 'omniauth-osm'
# Core Features
gem 'kaminari'
gem 'acts_as_taggable_on'sp
# Use ActiveModel has_secure_password # Devise instead
# gem 'bcrypt', '~> 3.1.7'
group :development do
#gem 'capistrano-rails'
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry-rails'
gem 'pry-byebug'
gem 'awesome_print'
gem 'quiet_assets'
gem 'annotate'
gem 'ruby_parser' # Convert HTML to Haml or Slim
end
group :test do
end
group :production do
gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment