Created
February 2, 2014 21:46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctype html | |
html | |
head | |
meta name="viewport" content="width=device-width, initial-scale=1.0" | |
title Paporeto | |
= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true | |
= csrf_meta_tags | |
/[if lt IE 9] | |
= javascript_include_tag "html5shiv", "data-turbolinks-track" => true | |
= javascript_include_tag "respond.min", "data-turbolinks-track" => true | |
body | |
- if user_signed_in? | |
.navbar.navbar-inverse.navbar-fixed-top | |
.container | |
.navbar-header | |
= link_to 'Paporeto', root_path, class: 'navbar-brand' | |
.navbar-collapse | |
ul.nav.navbar-nav | |
li class="#{nav_status('articles')}" = link_to 'Artigos', articles_path | |
li class="#{nav_status('categories')}" = link_to 'Categorias', categories_path | |
ul.nav.navbar-nav.pull-right | |
li = link_to 'Sair', destroy_user_session_path, method: :delete | |
.container | |
= yield | |
= javascript_include_tag "application", "data-turbolinks-track" => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "bootstrap" | |
body | |
margin-top: 60px | |
textarea.form-control | |
height: 250px | |
select.form-control | |
width: 120px | |
display: inline-block | |
input[type="checkbox"].form-control | |
display: inline | |
width: auto | |
height: auto | |
padding: 0 | |
box-shadow: none | |
label.control-label | |
padding: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ApplicationController | |
before_action :set_article, only: [:show, :edit, :update, :destroy] | |
before_action :authenticate_user! | |
# GET /articles | |
def index | |
@articles = Article.order(published_at: :desc).order(:title) | |
end | |
# GET /articles/1 | |
def show | |
end | |
# GET /articles/new | |
def new | |
@article = Article.new | |
end | |
# GET /articles/1/edit | |
def edit | |
end | |
# POST /articles | |
def create | |
@article = Article.new(article_params) | |
if @article.save | |
redirect_to @article, notice: 'Artigo salvo.' | |
else | |
render action: 'new' | |
end | |
end | |
# PATCH/PUT /articles/1 | |
def update | |
if @article.update(article_params) | |
redirect_to @article, notice: 'Artigo salvo.' | |
else | |
render action: 'edit' | |
end | |
end | |
# DELETE /articles/1 | |
def destroy | |
@article.destroy | |
redirect_to articles_url, notice: 'Artigo excluído.' | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_article | |
@article = Article.find(params[:id]) | |
end | |
# Only allow a trusted parameter "white list" through. | |
def article_params | |
params.require(:article).permit(:title, :body, :published_at, :category_id) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CategoriesController < ApplicationController | |
before_action :set_category, only: [:edit, :update, :destroy] | |
before_action :authenticate_user! | |
# GET /categories | |
def index | |
@categories = Category.all | |
end | |
# GET /categories/new | |
def new | |
@category = Category.new | |
end | |
# GET /categories/1/edit | |
def edit | |
end | |
# POST /categories | |
def create | |
@category = Category.new(category_params) | |
if @category.save | |
redirect_to categories_url | |
else | |
render action: 'new' | |
end | |
end | |
# PATCH/PUT /categories/1 | |
def update | |
if @category.update(category_params) | |
redirect_to categories_url | |
else | |
render action: 'edit' | |
end | |
end | |
# DELETE /categories/1 | |
def destroy | |
@category.destroy | |
redirect_to categories_url, notice: 'Category was successfully destroyed.' | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_category | |
@category = Category.find(params[:id]) | |
end | |
# Only allow a trusted parameter "white list" through. | |
def category_params | |
params.require(:category).permit(:name) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Paporeto::Application.configure do | |
# Settings specified here will take precedence over those in config/application.rb. | |
# In the development environment your application's code is reloaded on | |
# every request. This slows down response time but is perfect for development | |
# since you don't have to restart the web server when you make code changes. | |
config.cache_classes = false | |
# Do not eager load code on boot. | |
config.eager_load = false | |
# Show full error reports and disable caching. | |
config.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
# Don't care if the mailer can't send. | |
config.action_mailer.raise_delivery_errors = false | |
# Print deprecation notices to the Rails logger. | |
config.active_support.deprecation = :log | |
# Raise an error on page load if there are pending migrations | |
config.active_record.migration_error = :page_load | |
# Debug mode disables concatenation and preprocessing of assets. | |
# This option may cause significant delays in view rendering with a large | |
# number of complex assets. | |
config.assets.debug = true | |
config.action_controller.action_on_unpermitted_parameters = :raise | |
config.action_mailer.default_url_options = { :host => 'localhost:3000' } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pt-BR: | |
errors: | |
messages: | |
expired: 'expirou, por favor solicite um novo' | |
not_found: 'não encontrado' | |
already_confirmed: 'já foi confirmado, por favor tente fazer login' | |
not_locked: 'não estava bloqueado' | |
not_saved: | |
one: "1 erro impediu que %{resource} fosse salvo:" | |
other: "%{count} erros impediram que %{resource} fosse salvo:" | |
devise: | |
failure: | |
user: | |
not_found_in_database: 'Usuário não cadastrado.' | |
already_authenticated: 'Você já está logado.' | |
unauthenticated: 'Você precisa registrar-se ou fazer login para continuar.' | |
unconfirmed: 'Você deve confirmar sua conta antes de continuar.' | |
locked: 'Sua conta está bloqueada.' | |
invalid: 'E-mail ou senha inválidos' | |
invalid_token: 'Token de autenticação inválido.' | |
timeout: 'A sua sessão expirou, por favor faça login novamente para continuar.' | |
inactive: 'A sua conta não foi ativada ainda.' | |
sessions: | |
signed_in: 'Autenticado com sucesso.' | |
signed_out: 'Logout feito com sucesso.' | |
passwords: | |
send_instructions: 'Você receberá um e-mail com instruções sobre como reinicializar sua senha em poucos minutos.' | |
updated: 'Sua senha foi alterada com sucesso. Você está logado agora.' | |
updated_not_active: 'Sua senha foi alterada com sucesso.' | |
send_paranoid_instructions: 'Caso seu e-mail esteja cadastrado, você receberá um link para recuperação de senha no seu e-mail em poucos minutos.' | |
no_token: 'Você não pode acessar esta página sem que seja a partir de um e-mail de reinicialização de senha. Se você chegou aqui através de um e-mail de reinicialização de senha, por favor verifique se você usou a URL completa que foi informada.' | |
confirmations: | |
send_instructions: 'Dentro de minutos você receberá um e-mail com instruções para confirmar a sua conta.' | |
send_paranoid_instructions: 'Caso seu e-mail exista em nossa base, você receberá um e-mail em poucos minutos com instruções sobre como confirmar sua conta.' | |
confirmed: 'Sua conta foi confirmada com sucesso. Você está logado.' | |
registrations: | |
signed_up: 'Bem-vindo! Você se registrou com sucesso.' | |
signed_up_but_unconfirmed: 'Uma mensagem com um link de confirmação foi enviado para o seu e-mail. Por favor, abra o link para ativar sua conta.' | |
signed_up_but_inactive: 'Você se cadastrou com sucesso. Porém, sua conta ainda não está ativada.' | |
signed_up_but_locked: 'Você se cadastrou com sucesso. Porém, sua conta está bloqueada.' | |
updated: 'Você atualizou sua conta com sucesso.' | |
update_needs_confirmation: 'Você atualizou sua conta com sucesso, mas nós precisamos verificar seu endereço de e-mail. Por favor, verifique seus e-mails e clique no link de confirmação para finalizar a criação da sua conta.' | |
destroyed: 'Até mais! Sua conta foi cancelada com sucesso. Esperamos vê-lo novamente em breve.' | |
unlocks: | |
send_instructions: 'Você receberá um e-mail em poucos minutos com instruções sobre como desbloquear sua conta.' | |
unlocked: 'Sua conta foi desbloqueada com sucesso. Por favor, faça login para continuar.' | |
send_paranoid_instructions: 'Caso sua e-mail exista em nossa base, você receberá um e-mail em poucos minutos com instruções sobre como desbloqueá-la.' | |
omniauth_callbacks: | |
success: "Autorizado com sucesso pela conta %{kind}." | |
failure: 'Não foi possível autorizar você através do %{kind} porque "%{reason}".' | |
mailer: | |
confirmation_instructions: | |
subject: 'Instruções para confirmação de conta' | |
reset_password_instructions: | |
subject: 'Instruções para reinicialização de senha' | |
unlock_instructions: | |
subject: 'Instruções para desbloqueio de conta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeviseCreateUsers < ActiveRecord::Migration | |
def change | |
create_table(:users) do |t| | |
t.string :name | |
## Database authenticatable | |
t.string :email, :null => false, :default => "" | |
t.string :encrypted_password, :null => false, :default => "" | |
## Recoverable | |
t.string :reset_password_token | |
t.datetime :reset_password_sent_at | |
## Rememberable | |
t.datetime :remember_created_at | |
## Trackable | |
t.integer :sign_in_count, :default => 0, :null => false | |
t.datetime :current_sign_in_at | |
t.datetime :last_sign_in_at | |
t.string :current_sign_in_ip | |
t.string :last_sign_in_ip | |
## Confirmable | |
# t.string :confirmation_token | |
# t.datetime :confirmed_at | |
# t.datetime :confirmation_sent_at | |
# t.string :unconfirmed_email # Only if using reconfirmable | |
## Lockable | |
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts | |
# t.string :unlock_token # Only if unlock strategy is :email or :both | |
# t.datetime :locked_at | |
t.timestamps | |
end | |
add_index :users, :email, :unique => true | |
add_index :users, :reset_password_token, :unique => true | |
# add_index :users, :confirmation_token, :unique => true | |
# add_index :users, :unlock_token, :unique => true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
gem 'rails', '4.0.1' | |
# Use sqlite3 as the database for Active Record | |
gem 'sqlite3', '~> 1.3.8' | |
# Use SCSS for stylesheets | |
gem 'sass-rails', '~> 4.0.0' | |
# Use Uglifier as compressor for JavaScript assets | |
gem 'uglifier', '>= 1.3.0' | |
# Use CoffeeScript for .js.coffee assets and views | |
gem 'coffee-rails', '~> 4.0.0' | |
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | |
# gem 'therubyracer', platforms: :ruby | |
# Use jquery as the JavaScript library | |
gem 'jquery-rails', '~> 3.1.0' | |
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks | |
gem 'turbolinks', '~> 2.2.1' | |
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder | |
# gem 'jbuilder', '~> 1.2' | |
gem 'simple_form', '~> 3.0.1' | |
gem 'slim-rails', '~> 2.1.0' | |
gem 'xray-rails', '~> 0.1.12', group: :development | |
gem 'pry-rails', '~> 0.3.2', group: :development | |
gem 'start', '~> 0.1.1' | |
gem 'devise', '~> 3.2.2' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.row.vertical-offset-100 | |
.col-md-4.col-md-offset-4 | |
.panel.panel-default | |
.panel-heading | |
h2 Paporeto | |
.panel-body | |
- if alert | |
.alert.alert-warning.alert-dismissable | |
button type="button" class="close" data-dismiss="alert" aria-hidden="true" × | |
= alert | |
= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {autocomplete: 'off'}) do |f| | |
.form-inputs | |
= f.input :email, :required => false, label: false, placeholder: 'Email', :autofocus => true | |
= f.input :password, :required => false, label: false, placeholder: 'Senha' | |
= f.input :remember_me, :as => :boolean, label: 'Lembrar' if devise_mapping.rememberable? | |
.form-actions | |
= f.button :submit, "Entrar", class: 'btn btn-lg btn-success btn-block' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Paporeto::Application.routes.draw do | |
devise_for :users | |
resources :categories, except: :show | |
resources :articles | |
root 'articles#index' | |
# The priority is based upon order of creation: first created -> highest priority. | |
# See how all your routes lay out with "rake routes". | |
# You can have the root of your site routed with "root" | |
# root 'welcome#index' | |
# Example of regular route: | |
# get 'products/:id' => 'catalog#view' | |
# Example of named route that can be invoked with purchase_url(id: product.id) | |
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase | |
# Example resource route (maps HTTP verbs to controller actions automatically): | |
# resources :products | |
# Example resource route with options: | |
# resources :products do | |
# member do | |
# get 'short' | |
# post 'toggle' | |
# end | |
# | |
# collection do | |
# get 'sold' | |
# end | |
# end | |
# Example resource route with sub-resources: | |
# resources :products do | |
# resources :comments, :sales | |
# resource :seller | |
# end | |
# Example resource route with more complex sub-resources: | |
# resources :products do | |
# resources :comments | |
# resources :sales do | |
# get 'recent', on: :collection | |
# end | |
# end | |
# Example resource route with concerns: | |
# concern :toggleable do | |
# post 'toggle' | |
# end | |
# resources :posts, concerns: :toggleable | |
# resources :photos, concerns: :toggleable | |
# Example resource route within a namespace: | |
# namespace :admin do | |
# # Directs /admin/products/* to Admin::ProductsController | |
# # (app/controllers/admin/products_controller.rb) | |
# resources :products | |
# end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'has-error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label | |
b.use :input, :wrap_with => { :tag => 'div', :class => 'controls' } | |
b.use :error, :wrap_with => { :tag => 'span', :class => 'help-block' } | |
b.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } | |
end | |
config.form_class = "form-vertical" | |
config.input_class = "form-control" | |
config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label | |
b.wrapper tag: 'div', class: 'controls' do |input| | |
input.wrapper tag: 'div', class: 'input-prepend' do |prepend| | |
prepend.use :input | |
end | |
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } | |
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } | |
end | |
end | |
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label | |
b.wrapper tag: 'div', class: 'controls' do |input| | |
input.wrapper tag: 'div', class: 'input-append' do |append| | |
append.use :input | |
end | |
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } | |
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } | |
end | |
end | |
# Wrappers for forms and inputs using the Twitter Bootstrap toolkit. | |
# Check the Bootstrap docs (http://twitter.github.com/bootstrap) | |
# to learn about the different styles for forms and inputs, | |
# buttons and other elements. | |
config.default_wrapper = :bootstrap | |
config.wrappers :checkbox, :tag => 'div', :input_class => 'wwwwww' , :class => 'checkbox lorem ipsum', :error_class => 'has-error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label_input | |
end | |
config.wrapper_mappings = { :boolean => :checkbox } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# Include default devise modules. Others available are: | |
# :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment