From e8bf688442a3a5a1bad9cdb2d5c54092f4c14c93 Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 10:50:12 -0700 Subject: [PATCH 01/10] Updated README as a blog preview --- README.rdoc | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/README.rdoc b/README.rdoc index dd4e97e..40ee0fe 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,28 +1,19 @@ == README -This README would normally document whatever steps are necessary to get the -application up and running. +##Blog Features: -Things you may want to cover: +#Homepage -* Ruby version +- Site Navigation Bar on each page, with drop-down for Post Categories and user Log In / Sign Up / Log Out -* System dependencies +- Image carousel to highlight news/updates/features -* Configuration +- Recent blog posts featured -* Database creation +#Creating Post -* Database initialization +#Viewing Post -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. +- Includes Liking, Favouriting, UpVoting +- File Attachment previews: working on it +- Comment box for other viewers From 5566374004fc9afd82eec08958c558030f8bc205 Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 10:52:53 -0700 Subject: [PATCH 02/10] changed README to a markdown for formatting purposes --- README.rdoc => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.rdoc => README.md (100%) diff --git a/README.rdoc b/README.md similarity index 100% rename from README.rdoc rename to README.md From bd3f70e2084af0868d6996445c2cfa95f90f8e60 Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 10:53:37 -0700 Subject: [PATCH 03/10] fixed headers in README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 40ee0fe..530923e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ == README -##Blog Features: +#Blog Features: -#Homepage +##Homepage - Site Navigation Bar on each page, with drop-down for Post Categories and user Log In / Sign Up / Log Out @@ -10,9 +10,9 @@ - Recent blog posts featured -#Creating Post +##Creating Post -#Viewing Post +##Viewing Post - Includes Liking, Favouriting, UpVoting - File Attachment previews: working on it From ec9704f878d6bd742d4d9dc2a67d2492914c6aec Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 11:03:45 -0700 Subject: [PATCH 04/10] updated README features and goals --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 530923e..281bb0b 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,24 @@ -== README - #Blog Features: ##Homepage -- Site Navigation Bar on each page, with drop-down for Post Categories and user Log In / Sign Up / Log Out +### Site Navigation Bar: + * On each page + * Adding nested Drop-down for Post Index and Post Categories + * User Log In / Sign Up / Log Out -- Image carousel to highlight news/updates/features +### Image carousel to highlight news/updates/features -- Recent blog posts featured +### Recent blog posts featured + * Working on: Link in title and file preview on hover ##Creating Post +- Posts can have categories and tags in addition to the body and title +- Will be adding file attachments +- Can add user collaborators for the post for management ability ##Viewing Post - Includes Liking, Favouriting, UpVoting -- File Attachment previews: working on it +- File Attachment previews - Comment box for other viewers From 073748e3a8b40d11caaed6450653e6d242587af6 Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 11:05:20 -0700 Subject: [PATCH 05/10] fixed README styling --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 281bb0b..78064d0 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,24 @@ ##Homepage ### Site Navigation Bar: - * On each page - * Adding nested Drop-down for Post Index and Post Categories - * User Log In / Sign Up / Log Out + - On each page + - Adding nested Drop-down for Post Index and Post Categories + - User Log In / Sign Up / Log Out -### Image carousel to highlight news/updates/features +### Image carousel + - highlight news/updates/features + - Will implement clicking on image to link to parts of site ### Recent blog posts featured - * Working on: Link in title and file preview on hover + - Working on: Link in title and file preview on hover ##Creating Post -- Posts can have categories and tags in addition to the body and title -- Will be adding file attachments -- Can add user collaborators for the post for management ability + - Posts can have categories and tags in addition to the body and title + - Will be adding file attachments + - Can add user collaborators for the post for management ability ##Viewing Post -- Includes Liking, Favouriting, UpVoting -- File Attachment previews -- Comment box for other viewers + - Includes Liking, Favouriting, UpVoting + - File Attachment previews + - Comment box for other viewers From 6b5c255c548e0fbe39690353b0c7d0f428c01ab5 Mon Sep 17 00:00:00 2001 From: distienct Date: Mon, 29 Jun 2015 18:24:31 -0700 Subject: [PATCH 06/10] styled new/edit post forms with bootstrap --- Gemfile | 2 + Gemfile.lock | 4 + README.md | 6 +- app/assets/stylesheets/application.scss | 83 ++++++++++- app/controllers/posts_controller.rb | 8 +- app/models/ability.rb | 2 +- app/views/homes/about.html.erb | 8 +- app/views/layouts/application.html.erb | 2 +- app/views/posts/_form.html.erb | 49 ++++--- app/views/posts/edit.html.erb | 9 +- app/views/posts/new.html.erb | 10 +- config/initializers/simple_form.rb | 166 ++++++++++++++++++++++ config/locales/simple_form.en.yml | 31 ++++ lib/templates/erb/scaffold/_form.html.erb | 13 ++ 14 files changed, 356 insertions(+), 37 deletions(-) create mode 100644 config/initializers/simple_form.rb create mode 100644 config/locales/simple_form.en.yml create mode 100644 lib/templates/erb/scaffold/_form.html.erb diff --git a/Gemfile b/Gemfile index 839131d..347919b 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,8 @@ gem 'hirb' gem 'faker' gem 'cancancan' + +gem 'simple_form' # Use Unicorn as the app server # gem 'unicorn' diff --git a/Gemfile.lock b/Gemfile.lock index 70060c3..fc7d788 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,6 +132,9 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) + simple_form (3.1.0) + actionpack (~> 4.0) + activemodel (~> 4.0) spoon (0.0.4) ffi spring (1.3.6) @@ -177,6 +180,7 @@ DEPENDENCIES rails (= 4.2.1) sass-rails (~> 5.0) sdoc (~> 0.4.0) + simple_form spring turbolinks uglifier (>= 1.3.0) diff --git a/README.md b/README.md index 78064d0..d410f4f 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ ##Homepage -### Site Navigation Bar: +#### Site Navigation Bar: - On each page - Adding nested Drop-down for Post Index and Post Categories - User Log In / Sign Up / Log Out -### Image carousel +#### Image carousel - highlight news/updates/features - Will implement clicking on image to link to parts of site -### Recent blog posts featured +#### Recent blog posts featured - Working on: Link in title and file preview on hover ##Creating Post diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 2fde0c9..89d946e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -6,6 +6,7 @@ h5 { color: #0079a3; font-size: 35pt; + letter-spacing: 15px; margin-top: 25px; margin-bottom:5px; padding-top: 0px; @@ -36,7 +37,9 @@ .avatar { border-radius: 50%; } - +h1, h2, h3, h4 { + font-weight: lighter; +} .body { padding-left: 10px; padding-right: 10px; @@ -107,3 +110,81 @@ padding-bottom: 15px; border-bottom: 1px dotted #0079a3; } + +/*Simple Form Styling*/ +.form-group label { + display: block; + font-size: 16pt; + font-family: Arial; + font-weight: lighter; + color: #074c62; + text-align: left; + margin-right: 10px; +} + +.form-group input { + padding: 5px; + margin-bottom: 10px; + background-color: #ececec; + border: 3px solid #0079a3; + border-radius: 10px; + width: 650px; + height: 40px; +} + +.form-group textarea { + padding: 5px; + margin-bottom: 10px; + background-color: #ececec; + border: 3px solid #0079a3; + border-radius: 10px; + width: 650px; + height: 120px; +} + +#post_category_id { + width: 325px; + height: 40px; + border-radius: 10px; + background-color: #0079a3; + color: #FFFFFF; + font-weight: lighter; + text-transform: uppercase; +} +.form-control { + font-size: 14pt; + font-weight: lighter; + color: #999999; + background-color: #0079a3; + border-radius: 10px; +} +.check-boxes label { + background-color: #0079a3; + height: 40px; + padding: 5px; + border-radius: 10px; + margin-right: 8px; + color: #FFFFFF; + font-weight: lighter; + text-transform: uppercase; + .collection_check_boxes { + margin-left: 10px; + margin-right: 15px; + height: 30px; + } +} +.submit-button { + width: auto; + height: 40px; + margin-top: 35px; + margin-left: 5px; + padding-top: 0px; + padding-left: 5px; + padding-bottom: 5px; + border-radius: 5px; + color: #333333; + font-size: 18pt; + font-weight: lighter; + text-align: center; + background-color: #aaff77; +} diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 414eaf3..e187b70 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -3,7 +3,8 @@ class PostsController < ApplicationController before_action :find_post, only: [:edit, :update, :destroy, :show] before_action :authenticate_user!, except: [:index, :show] - before_action :authorize, only: [:edit, :update, :destroy] + before_action :authorize, only: [:edit] + before_action :authorize_delete, only: [:destroy] def index @posts = Post.page(params[:page]).per(8).order("id ASC") @@ -56,7 +57,10 @@ def find_post end def authorize - redirect_to root_path, alert: "Access denied." unless can? :manage, @post + redirect_to root_path, alert: "Access denied." unless can? :edit, @post end + def authorize_delete + redirect_to post_path(@post), alert: "Access denied" unless can? :destroy, @post + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index ff4087a..5703b98 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -13,7 +13,7 @@ def initialize(user) end can :manage, Comment do |comment| - comment.user == user + comment.user == user || post.collaborating_users.include?(user) end end end diff --git a/app/views/homes/about.html.erb b/app/views/homes/about.html.erb index b6fa616..0f65265 100644 --- a/app/views/homes/about.html.erb +++ b/app/views/homes/about.html.erb @@ -1,4 +1,6 @@ -

Hi, I'm Tien.

-

This is my about page

+
+

Hi, I'm Tien.

+

This is my about page

-<%= image_tag "http://i.imgur.com/9f4lbXW.jpg" %> + <%= image_tag "http://i.imgur.com/9f4lbXW.jpg" %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 70c46c0..f80c68f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,7 +12,7 @@
-
t h i s  i s  a  b l o g
+
this is a blog