diff --git a/Gemfile b/Gemfile index 1e4f013..0bc941f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,50 +1,34 @@ source 'https://rubygems.org' +ruby '2.2.0' -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.4' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1.0' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library gem 'jquery-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' -# bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc - gem 'font-awesome-sass' - - -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development +gem 'pygments.rb', '~>0.6.0' +gem 'redcarpet', '~>3.2.2' +gem 'friendly_id', '~> 5.1' +gem 'will_paginate', '~> 3.1' +gem 'mail_form', '~> 1.5', '>= 1.5.1' +gem 'devise', '~> 3.5', '>= 3.5.6' group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' + gem 'web-console', '~> 2.0' + gem 'spring' end group :development do - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' - - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' + gem 'sqlite3' end +group :production do + gem 'pg' + gem 'rails_12factor' +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 847a042..89e3b06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,7 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) + bcrypt (3.1.11) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) @@ -50,10 +51,19 @@ GEM coffee-script-source (1.10.0) concurrent-ruby (1.0.2) debug_inspector (0.0.2) + devise (3.5.10) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) erubis (2.7.0) execjs (2.6.0) font-awesome-sass (4.6.2) sass (>= 3.2) + friendly_id (5.1.0) + activerecord (>= 4.0.0) globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) @@ -69,6 +79,9 @@ GEM nokogiri (>= 1.5.9) mail (2.6.4) mime-types (>= 1.16, < 4) + mail_form (1.5.1) + actionmailer (>= 3.2, < 5) + activemodel (>= 3.2, < 5) mime-types (3.0) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) @@ -77,6 +90,12 @@ GEM multi_json (1.12.0) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) + orm_adapter (0.5.0) + pg (0.18.4) + posix-spawn (0.3.11) + pygments.rb (0.6.3) + posix-spawn (~> 0.3.6) + yajl-ruby (~> 1.2.0) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) @@ -99,6 +118,11 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.4) railties (4.2.4) actionpack (= 4.2.4) activesupport (= 4.2.4) @@ -107,6 +131,9 @@ GEM rake (11.1.2) rdoc (4.2.2) json (~> 1.4) + redcarpet (3.2.3) + responders (2.2.0) + railties (>= 4.2.0, < 5.1) sass (3.4.22) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) @@ -135,11 +162,15 @@ GEM thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) + warden (1.2.6) + rack (>= 1.0) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) + will_paginate (3.1.0) + yajl-ruby (1.2.1) PLATFORMS ruby @@ -147,10 +178,17 @@ PLATFORMS DEPENDENCIES byebug coffee-rails (~> 4.1.0) + devise (~> 3.5, >= 3.5.6) font-awesome-sass + friendly_id (~> 5.1) jbuilder (~> 2.0) jquery-rails + mail_form (~> 1.5, >= 1.5.1) + pg + pygments.rb (~> 0.6.0) rails (= 4.2.4) + rails_12factor + redcarpet (~> 3.2.2) sass-rails (~> 5.0) sdoc (~> 0.4.0) spring @@ -158,6 +196,7 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) + will_paginate (~> 3.1) BUNDLED WITH 1.10.6 diff --git a/app/assets/css/application.css.css b/app/assets/css/application.css.css new file mode 100644 index 0000000..254e551 --- /dev/null +++ b/app/assets/css/application.css.css @@ -0,0 +1,51 @@ +/* +Error: File to import not found or unreadable: normalize. + Load paths: + /Users/mohit/Desktop/Portfolio/Portfolio/app/assets/stylesheets + Sass::Globbing::Importer + on line 1 of /Users/mohit/Desktop/Portfolio/Portfolio/app/assets/stylesheets/application.css.scss + +1: @import 'normalize'; +2: +3: $dark: #424652; +4: $white: #FFFFFF; +5: $light: #9a9da4; +6: $highlight: #8bc6db; + +Backtrace: +/Users/mohit/Desktop/Portfolio/Portfolio/app/assets/stylesheets/application.css.scss:1 +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/import_node.rb:67:in `rescue in import' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/import_node.rb:45:in `import' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/import_node.rb:28:in `imported_file' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/import_node.rb:37:in `css_import?' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:311:in `visit_import' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:36:in `visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:158:in `block in visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/stack.rb:79:in `block in with_base' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/stack.rb:115:in `with_frame' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/stack.rb:79:in `with_base' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:158:in `visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:52:in `block in visit_children' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:52:in `map' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:52:in `visit_children' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:179:in `with_environment' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:166:in `visit_children' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:36:in `block in visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:186:in `visit_root' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/base.rb:36:in `visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:157:in `visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/visitors/perform.rb:8:in `visit' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/root_node.rb:36:in `css_tree' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/tree/root_node.rb:20:in `render' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/engine.rb:278:in `render' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/exec/sass_scss.rb:423:in `run' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/exec/sass_scss.rb:63:in `process_result' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/exec/base.rb:52:in `parse' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/lib/sass/exec/base.rb:19:in `parse!' +/Users/mohit/Downloads/CodeKit.app/Contents/Resources/engines/scss/bin/scss:13:in `
' +*/ +body:before { + white-space: pre; + font-family: monospace; + content: "Error: File to import not found or unreadable: normalize.\A Load paths:\A /Users/mohit/Desktop/Portfolio/Portfolio/app/assets/stylesheets\A Sass::Globbing::Importer\A on line 1 of /Users/mohit/Desktop/Portfolio/Portfolio/app/assets/stylesheets/application.css.scss\A \A 1: @import 'normalize';\A 2: \A 3: $dark: #424652;\A 4: $white: #FFFFFF;\A 5: $light: #9a9da4;\A 6: $highlight: #8bc6db;"; } diff --git a/app/assets/javascripts/contacts.coffee b/app/assets/javascripts/contacts.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/contacts.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/ diff --git a/app/assets/javascripts/projects.coffee b/app/assets/javascripts/projects.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/projects.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/ diff --git a/app/assets/stylesheets/.sass-cache/ab5c96180a20dcd6f1c0c702a2059ca1c5a69e5d/application.css.scssc b/app/assets/stylesheets/.sass-cache/ab5c96180a20dcd6f1c0c702a2059ca1c5a69e5d/application.css.scssc deleted file mode 100644 index c952072..0000000 Binary files a/app/assets/stylesheets/.sass-cache/ab5c96180a20dcd6f1c0c702a2059ca1c5a69e5d/application.css.scssc and /dev/null differ diff --git a/app/assets/stylesheets/_posts_projects.css.scss b/app/assets/stylesheets/_posts_projects.css.scss index 8940427..069a9a0 100644 --- a/app/assets/stylesheets/_posts_projects.css.scss +++ b/app/assets/stylesheets/_posts_projects.css.scss @@ -67,6 +67,23 @@ } +#admin_links { + border-top: 1px solid $border; + border-bottom: 1px solid $border; + text-align: center; + padding: 1em 0; + margin: 3em 0; + a { + color: $light; + margin: 0 1em; + font-weight: 700; + font-size: .8em; + text-decoration: none; + text-transform: uppercase; + } +} + + //---------Pagination .pagination:before, @@ -79,6 +96,7 @@ clear:box; } + .pagination { text-align: center; margin: 0 0 3em 0; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 5b68a18..cac9b1e 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -37,6 +37,17 @@ body{ clear: both; } +.hidden { + display: none; +} + +.notice, .alert { + text-align: center; + padding: 1em 0; + text-decoration: none; + border-bottom: 1px solid #E9E9E9; +} + h1, h2, h3, h4, h5, h6, p, ul, li { color: $dark; h1{ @@ -174,6 +185,19 @@ input[type="submit"], .button { } } +.project_button { + background: $highlight; + color: $white; + text-decoration: none; + padding: 1em 2em; +} + +.button_wrapper{ + margin: 4em 0 0 0; + text-align: center; +} + @import 'welcome'; @import 'posts_projects'; +@import 'pygments'; \ No newline at end of file diff --git a/app/assets/stylesheets/contacts.scss b/app/assets/stylesheets/contacts.scss new file mode 100644 index 0000000..d936d50 --- /dev/null +++ b/app/assets/stylesheets/contacts.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the contacts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/projects.scss b/app/assets/stylesheets/projects.scss new file mode 100644 index 0000000..d019266 --- /dev/null +++ b/app/assets/stylesheets/projects.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the projects controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/pygments.css.scss b/app/assets/stylesheets/pygments.css.scss new file mode 100644 index 0000000..44e7ef4 --- /dev/null +++ b/app/assets/stylesheets/pygments.css.scss @@ -0,0 +1,82 @@ +/* + Some simple Github-like styles, with syntax highlighting CSS via Pygments. +*/ + +pre{ + background-color: #eee; + padding: 1.5rem 3.5%; + margin: 2rem 0; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + overflow: auto; +} +code{ + background-color: #eee; + padding: 1px 3px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} + +.hll { background-color: #ffffcc } +.c { color: #999988; font-style: italic } /* Comment */ +.err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.k { color: #000000; font-weight: bold } /* Keyword */ +.o { color: #000000; font-weight: bold } /* Operator */ +.cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */ +.c1 { color: #999988; font-style: italic } /* Comment.Single */ +.cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.ge { color: #000000; font-style: italic } /* Generic.Emph */ +.gr { color: #aa0000 } /* Generic.Error */ +.gh { color: #999999 } /* Generic.Heading */ +.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.go { color: #888888 } /* Generic.Output */ +.gp { color: #555555 } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #aaaaaa } /* Generic.Subheading */ +.gt { color: #aa0000 } /* Generic.Traceback */ +.kc { color: #000000; font-weight: bold } /* Keyword.Constant */ +.kd { color: #000000; font-weight: bold } /* Keyword.Declaration */ +.kn { color: #000000; font-weight: bold } /* Keyword.Namespace */ +.kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */ +.kr { color: #000000; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.m { color: #009999 } /* Literal.Number */ +.s { color: #d01040 } /* Literal.String */ +.na { color: #008080 } /* Name.Attribute */ +.nb { color: #0086B3 } /* Name.Builtin */ +.nc { color: #445588; font-weight: bold } /* Name.Class */ +.no { color: #008080 } /* Name.Constant */ +.nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */ +.ni { color: #800080 } /* Name.Entity */ +.ne { color: #990000; font-weight: bold } /* Name.Exception */ +.nf { color: #990000; font-weight: bold } /* Name.Function */ +.nl { color: #990000; font-weight: bold } /* Name.Label */ +.nn { color: #555555 } /* Name.Namespace */ +.nt { color: #000080 } /* Name.Tag */ +.nv { color: #008080 } /* Name.Variable */ +.ow { color: #000000; font-weight: bold } /* Operator.Word */ +.w { color: #bbbbbb } /* Text.Whitespace */ +.mf { color: #009999 } /* Literal.Number.Float */ +.mh { color: #009999 } /* Literal.Number.Hex */ +.mi { color: #009999 } /* Literal.Number.Integer */ +.mo { color: #009999 } /* Literal.Number.Oct */ +.sb { color: #d01040 } /* Literal.String.Backtick */ +.sc { color: #d01040 } /* Literal.String.Char */ +.sd { color: #d01040 } /* Literal.String.Doc */ +.s2 { color: #d01040 } /* Literal.String.Double */ +.se { color: #d01040 } /* Literal.String.Escape */ +.sh { color: #d01040 } /* Literal.String.Heredoc */ +.si { color: #d01040 } /* Literal.String.Interpol */ +.sx { color: #d01040 } /* Literal.String.Other */ +.sr { color: #009926 } /* Literal.String.Regex */ +.s1 { color: #d01040 } /* Literal.String.Single */ +.ss { color: #990073 } /* Literal.String.Symbol */ +.bp { color: #999999 } /* Name.Builtin.Pseudo */ +.vc { color: #008080 } /* Name.Variable.Class */ +.vg { color: #008080 } /* Name.Variable.Global */ +.vi { color: #008080 } /* Name.Variable.Instance */ +.il { color: #009999 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb new file mode 100644 index 0000000..0876879 --- /dev/null +++ b/app/controllers/contacts_controller.rb @@ -0,0 +1,18 @@ +class ContactsController < ApplicationController + + def new + @contact = Contact.new + end + + def create + @contact = Contact.new(params[:contact]) + @contact.request = request + if @contact.deliver + flash.now[:error] = nil + else + flash.now[:error] = 'cannot send message.' + render :new + end + end + +end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 7cfa2e7..032a16e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,8 +1,10 @@ class PostsController < ApplicationController before_action :find_post, only: [:show, :update, :destroy, :edit] + before_action :authenticate_user!, except: [:index, :show] def index + @posts = Post.all.order("created_at desc").paginate(page: params[:page], per_page: 3) end @@ -43,10 +45,10 @@ def destroy private def post_params - params.require(:post).permit(:title,:content) + params.require(:post).permit(:title,:content, :slug) end def find_post - @post = Post.find(params[:id]) + @post = Post.friendly.find(params[:id]) end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb new file mode 100644 index 0000000..ed667f3 --- /dev/null +++ b/app/controllers/projects_controller.rb @@ -0,0 +1,53 @@ +class ProjectsController < ApplicationController + before_action :find_project, only: [:show, :edit, :update, :destroy] + before_action :authenticate_user!, except: [:index, :show] + + def index + @projects = Project.all.order("created_at desc") + end + + def new + @project = Project.new + end + + def create + @project = Project.new project_params + + if @project.save + redirect_to @project, notice: "Nice Mohit! Project was successfully saved!!!" + else + render 'new', notice: "Oops! Project couldn't be saved!!!" + end + end + + def show + + end + + def edit + + end + + def update + if @project.update project_params + redirect_to @project, notice: "Nice Mohit! Project was successfully updated!!!" + else + render 'edit', notice: "Oops! Project couldn't be updated!!!" + end + end + + def destroy + @project.destroy + redirect_to projects_path + end + + private + + def find_project + @project = Project.friendly.find(params[:id]) + end + + def project_params + params.require(:project).permit(:title, :description, :link, :slug) + end +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index d63ce63..4363d38 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -2,5 +2,6 @@ class WelcomeController < ApplicationController def index @posts = Post.all.limit(3).order("created_at desc") + @projects = Project.all.limit(3).order("created_at desc") end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..4bd55cf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,20 @@ module ApplicationHelper + class HTMLwithPygments < Redcarpet::Render::HTML + def block_code(code, language) + Pygments.highlight(code, lexer: language) + end + end + def markdown(content) + renderer = HTMLwithPygments.new(hard_wrap: true, filter_html:true) + options = { + autolink: true, + no_intra_emphasis: true, + disable_indented_code_blocks: true, + fenced_code_blocks: true, + lax_html_blocks: true, + strikethrough: true, + superscript: true + } + Redcarpet::Markdown.new(renderer, options).render(content).html_safe + end end diff --git a/app/helpers/contacts_helper.rb b/app/helpers/contacts_helper.rb new file mode 100644 index 0000000..593025b --- /dev/null +++ b/app/helpers/contacts_helper.rb @@ -0,0 +1,2 @@ +module ContactsHelper +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb new file mode 100644 index 0000000..db5c5ce --- /dev/null +++ b/app/helpers/projects_helper.rb @@ -0,0 +1,2 @@ +module ProjectsHelper +end diff --git a/app/models/contact.rb b/app/models/contact.rb new file mode 100644 index 0000000..c9889e7 --- /dev/null +++ b/app/models/contact.rb @@ -0,0 +1,14 @@ +class Contact < MailForm::Base + attribute :name, :validate => true + attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i + attribute :message, :validate => true + attribute :nickname, :captcha => true + + def headers + { + :subject => "Contact Form", + :to => "chandanamohit@gmail.com", + :from => %("#{name}" <#{email}>) + } + end +end \ No newline at end of file diff --git a/app/models/post.rb b/app/models/post.rb index 791dcb5..2d666bb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,2 +1,4 @@ class Post < ActiveRecord::Base + extend FriendlyId + friendly_id :title, use: :slugged end diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 0000000..bb4989b --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,4 @@ +class Project < ActiveRecord::Base + extend FriendlyId + friendly_id :title, use: :slugged +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..136dba5 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,5 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable +end diff --git a/app/views/contacts/create.html.erb b/app/views/contacts/create.html.erb new file mode 100644 index 0000000..113a1c1 --- /dev/null +++ b/app/views/contacts/create.html.erb @@ -0,0 +1,6 @@ +

Say Hello!

+ +
+

Thank you for your message

+

I will get back to you soon!

+
\ No newline at end of file diff --git a/app/views/contacts/new.html.erb b/app/views/contacts/new.html.erb new file mode 100644 index 0000000..238c02e --- /dev/null +++ b/app/views/contacts/new.html.erb @@ -0,0 +1,25 @@ +

Say Hello!

+ +
+ + <%= form_for @contact do |f| %> + + <%= f.label :name %>
+ <%= f.text_field :name, required: true %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, required: true %> +
+ <%= f.label :message %>
+ <%= f.text_area :message, as: :text %> + + + + <%= f.submit 'Send Message', class: "button"%> + + <% end %> + +
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..826672f --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,16 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> +
+ +
+ <%= f.submit "Resend confirmation instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..dc55f64 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb new file mode 100644 index 0000000..b41daf4 --- /dev/null +++ b/app/views/devise/mailer/password_change.html.erb @@ -0,0 +1,3 @@ +

Hello <%= @resource.email %>!

+ +

We're contacting you to notify you that your password has been changed.

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..f667dc1 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password. You can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..41e148b --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..6a796b0 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,25 @@ +

Change your password

+ +<%= 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 %> + +
+ <%= f.label :password, "New password" %>
+ <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum)
+ <% end %> + <%= f.password_field :password, autofocus: true, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.submit "Change my password" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..3d6d11a --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,16 @@ +

Forgot your password?

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.submit "Send me reset password instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..3ea40f0 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,39 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> + +
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "off" %> +
+ +
+ <%= f.submit "Update" %> +
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..5a238ce --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,29 @@ +

Sign up

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.label :password %> + <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum) + <% end %>
+ <%= f.password_field :password, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.submit "Sign up" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..e0de82d --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,30 @@ +

Log in

+ +
+ + +<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "off" %> +
+ + <% if devise_mapping.rememberable? -%> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+ <% end -%> +
+
+ <%= f.submit "Log in" %> +
+<% end %> + + +
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb new file mode 100644 index 0000000..e6a3e41 --- /dev/null +++ b/app/views/devise/shared/_links.html.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Log in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..16586bc --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,16 @@ +

Resend unlock instructions

+ +<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.submit "Resend unlock instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f5dabae..c188a99 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,11 +15,20 @@ <%= link_to "Mohit Chandana", root_path, class: "name" %> + <% if notice %> +

<%= notice %>

+ <% elsif alert %> +

<%= alert %>

+ <% end %> + <%= yield %>