Permalink
Browse files

Added cms/pages and some bootstrap styles, began devise setup

  • Loading branch information...
josephhays committed May 24, 2016
1 parent e90fe84 commit 1e03ac0c150e8063ff60b13e2f960d4f3da567a3
Showing with 929 additions and 18 deletions.
  1. +2 −0 app/assets/javascripts/application.js
  2. +3 −0 app/assets/javascripts/cms/pages.coffee
  3. +0 −15 app/assets/stylesheets/application.css
  4. +7 −0 app/assets/stylesheets/application.css.scss
  5. +3 −0 app/assets/stylesheets/cms/pages.scss
  6. +74 −0 app/controllers/cms/pages_controller.rb
  7. +2 −0 app/helpers/cms/pages_helper.rb
  8. +5 −0 app/models/cms.rb
  9. +2 −0 app/models/cms/page.rb
  10. +6 −0 app/models/user.rb
  11. +32 −0 app/views/cms/pages/_form.html.erb
  12. +3 −0 app/views/cms/pages/edit.html.erb
  13. +34 −0 app/views/cms/pages/index.html.erb
  14. +4 −0 app/views/cms/pages/index.json.jbuilder
  15. +3 −0 app/views/cms/pages/new.html.erb
  16. +14 −0 app/views/cms/pages/show.html.erb
  17. +1 −0 app/views/cms/pages/show.json.jbuilder
  18. +16 −0 app/views/devise/confirmations/new.html.erb
  19. +5 −0 app/views/devise/mailer/confirmation_instructions.html.erb
  20. +3 −0 app/views/devise/mailer/password_change.html.erb
  21. +8 −0 app/views/devise/mailer/reset_password_instructions.html.erb
  22. +7 −0 app/views/devise/mailer/unlock_instructions.html.erb
  23. +25 −0 app/views/devise/passwords/edit.html.erb
  24. +16 −0 app/views/devise/passwords/new.html.erb
  25. +39 −0 app/views/devise/registrations/edit.html.erb
  26. +29 −0 app/views/devise/registrations/new.html.erb
  27. +26 −0 app/views/devise/sessions/new.html.erb
  28. +25 −0 app/views/devise/shared/_links.html.erb
  29. +16 −0 app/views/devise/unlocks/new.html.erb
  30. +9 −3 app/views/layouts/application.html.erb
  31. +268 −0 config/initializers/devise.rb
  32. +62 −0 config/locales/devise.en.yml
  33. +4 −0 config/routes.rb
  34. +42 −0 db/migrate/20160523205633_devise_create_users.rb
  35. +10 −0 db/migrate/20160523210317_create_cms_pages.rb
  36. +41 −0 db/schema.rb
  37. +49 −0 test/controllers/cms/pages_controller_test.rb
  38. +9 −0 test/fixtures/cms/pages.yml
  39. +11 −0 test/fixtures/users.yml
  40. +7 −0 test/models/cms/page_test.rb
  41. +7 −0 test/models/user_test.rb
@@ -13,4 +13,6 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require tinymce-jquery
//= require_tree .
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,7 @@
@import 'bootstrap-sprockets';
@import 'bootstrap';
html, body {
margin: 0px;
padding: 0px;
}
@@ -0,0 +1,3 @@
// Place all the styles related to the CMS::Pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,74 @@
class Cms::PagesController < ApplicationController
before_action :set_cms_page, only: [:show, :edit, :update, :destroy]
# GET /cms/pages
# GET /cms/pages.json
def index
@cms_pages = Cms::Page.all
end
# GET /cms/pages/1
# GET /cms/pages/1.json
def show
end
# GET /cms/pages/new
def new
@cms_page = Cms::Page.new
end
# GET /cms/pages/1/edit
def edit
end
# POST /cms/pages
# POST /cms/pages.json
def create
@cms_page = Cms::Page.new(cms_page_params)
respond_to do |format|
if @cms_page.save
format.html { redirect_to @cms_page, notice: 'Page was successfully created.' }
format.json { render :show, status: :created, location: @cms_page }
else
format.html { render :new }
format.json { render json: @cms_page.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /cms/pages/1
# PATCH/PUT /cms/pages/1.json
def update
respond_to do |format|
if @cms_page.update(cms_page_params)
format.html { redirect_to @cms_page, notice: 'Page was successfully updated.' }
format.json { render :show, status: :ok, location: @cms_page }
else
format.html { render :edit }
format.json { render json: @cms_page.errors, status: :unprocessable_entity }
end
end
end
# DELETE /cms/pages/1
# DELETE /cms/pages/1.json
def destroy
@cms_page.destroy
respond_to do |format|
format.html { redirect_to cms_pages_url, notice: 'Page was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_cms_page
@cms_page = Cms::Page.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def cms_page_params
params.require(:cms_page).permit(:title, :content)
end
end
@@ -0,0 +1,2 @@
module Cms::PagesHelper
end
View
@@ -0,0 +1,5 @@
module Cms
def self.table_name_prefix
'cms_'
end
end
View
@@ -0,0 +1,2 @@
class Cms::Page < ActiveRecord::Base
end
View
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,32 @@
<%= form_for(@cms_page) do |f| %>
<% if @cms_page.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@cms_page.errors.count, "error") %> prohibited this cms_page from being saved:</h2>
<ul>
<% @cms_page.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row">
<div class="col-lg-10">
<div class="form-group well">
<%= f.label :title %><br>
<%= f.text_field :title, class: "form-control" %>
</div>
<div class="form-goup well">
<%= f.label :content %><br>
<%= f.text_area :content, class: "form-control" %>
</div>
</div>
<div class="col-lg-2">
<div class="btn-group-vertical btn-block" role="group" aria="...">
<%= f.submit 'Save', class: "btn btn-primary btn-block" %>
<%= link_to 'Back', cms_pages_path, class: "btn btn-danger btn-block" %>
</div>
</div>
</div>
<% end %>
@@ -0,0 +1,3 @@
<h1>Editing Cms Page</h1>
<%= render 'form' %>
@@ -0,0 +1,34 @@
<p id="notice"><%= notice %></p>
<h1>Pages</h1>
<div class="row">
<div class="col-lg-10">
<% @cms_pages.each do |cms_page| %>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%= cms_page.title %></h3>
</div>
<div class="panel-body">
<%= cms_page.content.truncate(100) %>
</div>
<div class="panel-footer">
<%= link_to edit_cms_page_path(cms_page), class: "btn btn-primary" do %>
<span class="glyphicon glyphicon-pencil"></span> Edit&nbsp;
<% end %>
<%= link_to cms_page, class: "btn btn-primary" do %>
<span class="glyphicon glyphicon-new-window"></span> Visit&nbsp;
<% end %>
<%= link_to cms_page, class: "btn btn-danger", method: :delete, data: { confirm: 'Are you sure?' } do %>
<span class="glyphicon glyphicon-trash"></span> Delete&nbsp;
<% end %>
</div>
</div>
<% end %>
</div>
<div class="col-lg-2">
<%= link_to 'New Page', new_cms_page_path, class: "btn btn-primary btn-block" %>
</div>
</div>
@@ -0,0 +1,4 @@
json.array!(@cms_pages) do |cms_page|
json.extract! cms_page, :id, :title, :content
json.url cms_page_url(cms_page, format: :json)
end
@@ -0,0 +1,3 @@
<h1>New Cms Page</h1>
<%= render 'form' %>
@@ -0,0 +1,14 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @cms_page.title %>
</p>
<p>
<strong>Content:</strong>
<%= @cms_page.content %>
</p>
<%= link_to 'Edit', edit_cms_page_path(@cms_page) %> |
<%= link_to 'Back', cms_pages_path %>
@@ -0,0 +1 @@
json.extract! @cms_page, :id, :title, :content, :created_at, :updated_at
@@ -0,0 +1,16 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
@@ -0,0 +1,5 @@
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
@@ -0,0 +1,25 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
@@ -0,0 +1,16 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
@@ -0,0 +1,39 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>
@@ -0,0 +1,29 @@
<h2>Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
Oops, something went wrong.

0 comments on commit 1e03ac0

Please sign in to comment.