Skip to content

Commit

Permalink
Added cms/pages and some bootstrap styles, began devise setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Hays committed May 24, 2016
1 parent e90fe84 commit 1e03ac0
Show file tree
Hide file tree
Showing 41 changed files with 929 additions and 18 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -13,4 +13,6 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require tinymce-jquery
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/cms/pages.coffee
@@ -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/
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

7 changes: 7 additions & 0 deletions app/assets/stylesheets/application.css.scss
@@ -0,0 +1,7 @@
@import 'bootstrap-sprockets';
@import 'bootstrap';

html, body {
margin: 0px;
padding: 0px;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/cms/pages.scss
@@ -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/
74 changes: 74 additions & 0 deletions app/controllers/cms/pages_controller.rb
@@ -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
2 changes: 2 additions & 0 deletions app/helpers/cms/pages_helper.rb
@@ -0,0 +1,2 @@
module Cms::PagesHelper
end
5 changes: 5 additions & 0 deletions app/models/cms.rb
@@ -0,0 +1,5 @@
module Cms
def self.table_name_prefix
'cms_'
end
end
2 changes: 2 additions & 0 deletions app/models/cms/page.rb
@@ -0,0 +1,2 @@
class Cms::Page < ActiveRecord::Base
end
6 changes: 6 additions & 0 deletions app/models/user.rb
@@ -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
32 changes: 32 additions & 0 deletions app/views/cms/pages/_form.html.erb
@@ -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 %>
3 changes: 3 additions & 0 deletions app/views/cms/pages/edit.html.erb
@@ -0,0 +1,3 @@
<h1>Editing Cms Page</h1>

<%= render 'form' %>
34 changes: 34 additions & 0 deletions app/views/cms/pages/index.html.erb
@@ -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>
4 changes: 4 additions & 0 deletions app/views/cms/pages/index.json.jbuilder
@@ -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
3 changes: 3 additions & 0 deletions app/views/cms/pages/new.html.erb
@@ -0,0 +1,3 @@
<h1>New Cms Page</h1>

<%= render 'form' %>
14 changes: 14 additions & 0 deletions app/views/cms/pages/show.html.erb
@@ -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 %>
1 change: 1 addition & 0 deletions app/views/cms/pages/show.json.jbuilder
@@ -0,0 +1 @@
json.extract! @cms_page, :id, :title, :content, :created_at, :updated_at
16 changes: 16 additions & 0 deletions app/views/devise/confirmations/new.html.erb
@@ -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" %>
5 changes: 5 additions & 0 deletions app/views/devise/mailer/confirmation_instructions.html.erb
@@ -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>
3 changes: 3 additions & 0 deletions app/views/devise/mailer/password_change.html.erb
@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>

<p>We're contacting you to notify you that your password has been changed.</p>
8 changes: 8 additions & 0 deletions app/views/devise/mailer/reset_password_instructions.html.erb
@@ -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>
7 changes: 7 additions & 0 deletions app/views/devise/mailer/unlock_instructions.html.erb
@@ -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>
25 changes: 25 additions & 0 deletions app/views/devise/passwords/edit.html.erb
@@ -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" %>
16 changes: 16 additions & 0 deletions app/views/devise/passwords/new.html.erb
@@ -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" %>
39 changes: 39 additions & 0 deletions app/views/devise/registrations/edit.html.erb
@@ -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 %>
29 changes: 29 additions & 0 deletions app/views/devise/registrations/new.html.erb
@@ -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" %>

0 comments on commit 1e03ac0

Please sign in to comment.