home_page 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/fonts/socialicious.eot +0 -0
  3. data/app/assets/fonts/socialicious.svg +84 -0
  4. data/app/assets/fonts/socialicious.ttf +0 -0
  5. data/app/assets/fonts/socialicious.woff +0 -0
  6. data/app/assets/stylesheets/home_page/application.css +3 -0
  7. data/app/assets/stylesheets/home_page/base.less +1 -1
  8. data/app/assets/stylesheets/home_page/bootswatch.css.less +5 -1
  9. data/app/assets/stylesheets/home_page/loader.css.less +2 -2
  10. data/app/assets/stylesheets/home_page/pygments.css +63 -0
  11. data/app/assets/stylesheets/home_page/sign_in.css +40 -0
  12. data/app/assets/stylesheets/home_page/socialicious.css +655 -0
  13. data/app/controllers/devise_extensions/registrations_controller.rb +1 -1
  14. data/app/controllers/devise_extensions/sessions_controller.rb +21 -0
  15. data/app/controllers/home_page/application_controller.rb +22 -0
  16. data/app/controllers/users_controller.rb +0 -2
  17. data/app/helpers/home_page/application_helper.rb +34 -0
  18. data/app/helpers/home_page/layout_helper.rb +2 -2
  19. data/app/models/user.rb +4 -0
  20. data/app/views/devise/sessions/new.html.erb +9 -0
  21. data/app/views/layouts/application.html.erb +9 -29
  22. data/app/views/layouts/home_page/sign_in.html.erb +11 -0
  23. data/app/views/layouts/shared/_flash.html.erb +3 -0
  24. data/app/views/layouts/shared/_foot.html.erb +1 -0
  25. data/app/views/layouts/shared/_head.html.erb +10 -0
  26. data/app/views/layouts/shared/_navigation.html.erb +14 -0
  27. data/app/views/users/_form.html.erb +3 -1
  28. data/config/initializers/assets.rb +1 -0
  29. data/config/initializers/friendly_id.rb +88 -0
  30. data/config/locales/general/en.yml +6 -0
  31. data/config/locales/resources/tag/en.yml +4 -0
  32. data/config/routes.rb +4 -1
  33. data/db/migrate/20150307152542_create_initial_schema.rb +2 -3
  34. data/db/migrate/20150307193102_create_friendly_id_slugs.rb +15 -0
  35. data/lib/home_page.rb +9 -0
  36. data/lib/home_page/engine.rb +6 -0
  37. data/lib/home_page/navigation.rb +13 -2
  38. data/lib/home_page/version.rb +1 -1
  39. metadata +146 -3
  40. data/config/initializers/devise.rb +0 -259
@@ -3,7 +3,7 @@ class DeviseExtensions::RegistrationsController < Devise::RegistrationsControlle
3
3
  def create
4
4
  build_resource(params[:user])
5
5
 
6
- captcha_verified = if Rails.env == 'development' || Rails.env == 'production'
6
+ captcha_verified = if Rails.env == 'production'
7
7
  verify_recaptcha(model: resource, message: I18n.t('general.exceptions.wrong_recaptcha'))
8
8
  else
9
9
  true
@@ -0,0 +1,21 @@
1
+ class DeviseExtensions::SessionsController < Devise::SessionsController
2
+ layout :layout_by_resource
3
+
4
+ # GET /resource/sign_in
5
+ def new
6
+ @home_page_stylesheets = ['home_page/application', 'home_page/sign_in']
7
+ self.resource = resource_class.new(sign_in_params)
8
+ clean_up_passwords(resource)
9
+ respond_with(resource, serialize_options(resource))
10
+ end
11
+
12
+ protected
13
+
14
+ def layout_by_resource
15
+ if devise_controller? && resource_name == :user && action_name == 'new'
16
+ 'home_page/sign_in'
17
+ else
18
+ 'application'
19
+ end
20
+ end
21
+ end
@@ -7,7 +7,29 @@ class HomePage::ApplicationController < ActionController::Base
7
7
 
8
8
  rescue_from ActiveRecord::RecordNotFound, with: :not_found
9
9
 
10
+ helper_method :home_page_stylesheets, :home_page_javascripts, :resource
11
+
12
+ before_filter :custom_view_path
13
+
14
+ def home_page_stylesheets
15
+ @home_page_stylesheets || ['home_page/application']
16
+ end
17
+
18
+ def home_page_javascripts
19
+ @home_page_javascripts || ['home_page/application']
20
+ end
21
+
22
+ protected
23
+
24
+ def show_breadcrumbs
25
+ @show_breadcrumbs = true
26
+ end
27
+
10
28
  private
29
+
30
+ def custom_view_path
31
+ prepend_view_path 'app/views/custom'
32
+ end
11
33
 
12
34
  def not_found(e)
13
35
  if Rails.env.development?
@@ -3,8 +3,6 @@ class UsersController < ApplicationController
3
3
 
4
4
  respond_to :html
5
5
 
6
- helper_method :resource
7
-
8
6
  before_filter :authenticate_user!
9
7
 
10
8
  def index
@@ -1,5 +1,7 @@
1
1
  module HomePage
2
2
  module ApplicationHelper
3
+ include AutoHtml
4
+
3
5
  # Taken from https://github.com/seyhunak/twitter-bootstrap-rails
4
6
  # Modified to support html in flash message
5
7
  def bootstrap_flash_raw
@@ -22,5 +24,37 @@ module HomePage
22
24
 
23
25
  flash_messages.join("\n").html_safe
24
26
  end
27
+
28
+ def markdown(text)
29
+ syntax_highlighter(
30
+ auto_html(text) do
31
+ youtube(width: 515, height: 300)
32
+ dailymotion(width: 515, height: 300)
33
+ vimeo(width: 515, height: 300)
34
+ google_video(width: 515, height: 300)
35
+ image
36
+
37
+ redcarpet(
38
+ renderer: Redcarpet::Render::XHTML.new(
39
+ no_images: true, no_styles: true, hard_wrap: true, with_toc_data: true
40
+ ),
41
+ markdown_options: { no_intra_emphasis: true, autolink: true, fenced_code_blocks: true }
42
+ )
43
+ link :target => "_blank", :rel => "nofollow"
44
+ end.gsub(/(>https?:\/\/[^\<\\]+)/) do |match|
45
+ truncate(match)
46
+ end.gsub('<pre>', '').gsub('</pre>', '')
47
+ ).html_safe
48
+ end
49
+
50
+ def syntax_highlighter(html)
51
+ doc = Nokogiri::HTML(html)
52
+
53
+ doc.search("//code[@class]").each do |code|
54
+ code.replace Albino.colorize(code.text.rstrip, code[:class])
55
+ end
56
+
57
+ doc.to_s
58
+ end
25
59
  end
26
60
  end
@@ -1,7 +1,7 @@
1
1
  module HomePage
2
2
  module LayoutHelper
3
3
  def breadcrumbs
4
- result = render_navigation context: application_navigation, renderer: :breadcrumbs_without_method_links, join_with: ' &gt; '
4
+ result = render_navigation context: :main, renderer: :breadcrumbs_without_method_links, join_with: ' &gt; '
5
5
  result = result && result.scan('<a').length > 1 ? result : ''
6
6
 
7
7
  if respond_to?(:resource) && resource.respond_to?(:ancestors)
@@ -21,7 +21,7 @@ module HomePage
21
21
 
22
22
  def sidenav(links_count = 2)
23
23
  links_count ||= 2
24
- result = render_navigation context: application_navigation, renderer: :twitter_sidenav, level: @twitter_sidenav_level
24
+ result = render_navigation context: :main, renderer: :twitter_sidenav, level: @twitter_sidenav_level
25
25
 
26
26
  result && result.scan('<a').length >= links_count ? result : ''
27
27
  end
data/app/models/user.rb CHANGED
@@ -17,4 +17,8 @@ class User < ActiveRecord::Base
17
17
  user.skip_confirmation_notification!
18
18
  user.confirmation_sent_at = nil
19
19
  end
20
+
21
+ def full_name
22
+ "#{first_name} #{last_name}"
23
+ end
20
24
  end
@@ -0,0 +1,9 @@
1
+ <%= simple_form_for resource, as: resource_name, url: session_path(resource_name), html: { class: 'form-signin' } do |f| %>
2
+ <h2 class="form-signin-heading"><%= t('general.sign_in_title') %></h2>
3
+ <%= f.input :email %>
4
+ <%= f.input :password %>
5
+ <%= f.input :remember_me, as: :boolean, label: false, inline_label: t('general.remember_me') %>
6
+ <%= f.submit t('general.sign_in'), class: 'btn btn-lg btn-primary btn-block' %>
7
+ <br/>
8
+ <%= render 'devise/shared/links' %>
9
+ <% end %>
@@ -1,43 +1,23 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title><%= (yield(:title).blank? ? '' : yield(:title) + ' - ') + t('general.site.title') %></title>
8
- <%= stylesheet_link_tag 'home_page/application', media: 'all' %>
9
- <%= csrf_meta_tags %>
10
- <link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"/>
11
- <link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"/>
12
- <link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"/>
13
- <link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"/>
4
+ <%= render partial: 'layouts/shared/head' %>
14
5
  </head>
15
6
  <body>
16
- <div class="navbar navbar-inverse navbar-fixed-top">
17
- <div class="container">
18
- <div class="navbar-header">
19
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
20
- <span class="icon-bar"></span>
21
- <span class="icon-bar"></span>
22
- <span class="icon-bar"></span>
23
- </button>
24
- <a class="navbar-brand" href="#"><%= t('general.site.title') %></a>
25
- </div>
26
-
27
- <%= render_navigation context: :main, expand_all: false, renderer: :bootstrap %>
28
- </div>
29
- </div>
7
+ <%= render partial: 'layouts/shared/navigation' %>
30
8
 
31
9
  <div class="container">
32
- <div id="flash">
33
- <%= bootstrap_flash_raw %>
34
- </div>
35
-
10
+ <%= render partial: 'layouts/shared/flash' %>
11
+
36
12
  <div class="content">
37
13
  <% if content_for?(:title) %>
38
14
  <div class="row">
39
15
  <div class="col-md-12">
40
16
  <div class="page-header">
17
+ <% if @show_breadcrumbs %>
18
+ <%= raw breadcrumbs %><br/>
19
+ <% end %>
20
+
41
21
  <h2 id="title"><%= yield :title %></h2>
42
22
  </div>
43
23
  </div>
@@ -51,6 +31,6 @@
51
31
  </div>
52
32
  </div>
53
33
 
54
- <%= javascript_include_tag 'home_page/application' %>
34
+ <%= render partial: 'layouts/shared/foot' %>
55
35
  </body>
56
36
  </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <%= render partial: 'layouts/shared/head' %>
5
+ </head>
6
+ <body>
7
+ <div class="container">
8
+ <%= yield %>
9
+ </div>
10
+ </body>
11
+ </html>
@@ -0,0 +1,3 @@
1
+ <div id="flash">
2
+ <%= bootstrap_flash_raw %>
3
+ </div>
@@ -0,0 +1 @@
1
+ <%= javascript_include_tag *home_page_javascripts %>
@@ -0,0 +1,10 @@
1
+ <meta charset="utf-8">
2
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
3
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
4
+ <title><%= (yield(:title).blank? ? '' : yield(:title) + ' - ') + t('general.site.title') %></title>
5
+ <%= stylesheet_link_tag *home_page_stylesheets, media: 'all' %>
6
+ <%= csrf_meta_tags %>
7
+ <link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"/>
8
+ <link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"/>
9
+ <link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"/>
10
+ <link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"/>
@@ -0,0 +1,14 @@
1
+ <div class="navbar navbar-inverse navbar-fixed-top">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
5
+ <span class="icon-bar"></span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ </button>
9
+ <a class="navbar-brand" href="<%= root_path %>"><%= t('general.index.title') %></a>
10
+ </div>
11
+
12
+ <%= render_navigation context: :main, expand_all: false, renderer: :bootstrap %>
13
+ </div>
14
+ </div>
@@ -14,8 +14,10 @@
14
14
 
15
15
  <div class="form-group">
16
16
  <div class="col-sm-offset-3 col-sm-9">
17
- <%= recaptcha_tags if resource.new_record? && (Rails.env == 'production' || Rails.env == 'development') %>
17
+ <% if resource.new_record? && (Rails.env == 'production') %>
18
+ <%= recaptcha_tags %>
18
19
  <br/>
20
+ <% end %>
19
21
  <%= f.button :submit %>
20
22
  <br/>
21
23
  <br/>
@@ -0,0 +1 @@
1
+ #Rails.application.config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
@@ -0,0 +1,88 @@
1
+ # FriendlyId Global Configuration
2
+ #
3
+ # Use this to set up shared configuration options for your entire application.
4
+ # Any of the configuration options shown here can also be applied to single
5
+ # models by passing arguments to the `friendly_id` class method or defining
6
+ # methods in your model.
7
+ #
8
+ # To learn more, check out the guide:
9
+ #
10
+ # http://norman.github.io/friendly_id/file.Guide.html
11
+
12
+ FriendlyId.defaults do |config|
13
+ # ## Reserved Words
14
+ #
15
+ # Some words could conflict with Rails's routes when used as slugs, or are
16
+ # undesirable to allow as slugs. Edit this list as needed for your app.
17
+ config.use :reserved
18
+
19
+ config.reserved_words = %w(new edit index session login logout users admin
20
+ stylesheets assets javascripts images)
21
+
22
+ # ## Friendly Finders
23
+ #
24
+ # Uncomment this to use friendly finders in all models. By default, if
25
+ # you wish to find a record by its friendly id, you must do:
26
+ #
27
+ # MyModel.friendly.find('foo')
28
+ #
29
+ # If you uncomment this, you can do:
30
+ #
31
+ # MyModel.find('foo')
32
+ #
33
+ # This is significantly more convenient but may not be appropriate for
34
+ # all applications, so you must explicity opt-in to this behavior. You can
35
+ # always also configure it on a per-model basis if you prefer.
36
+ #
37
+ # Something else to consider is that using the :finders addon boosts
38
+ # performance because it will avoid Rails-internal code that makes runtime
39
+ # calls to `Module.extend`.
40
+ #
41
+ # config.use :finders
42
+ #
43
+ # ## Slugs
44
+ #
45
+ # Most applications will use the :slugged module everywhere. If you wish
46
+ # to do so, uncomment the following line.
47
+ #
48
+ # config.use :slugged
49
+ #
50
+ # By default, FriendlyId's :slugged addon expects the slug column to be named
51
+ # 'slug', but you can change it if you wish.
52
+ #
53
+ # config.slug_column = 'slug'
54
+ #
55
+ # When FriendlyId can not generate a unique ID from your base method, it appends
56
+ # a UUID, separated by a single dash. You can configure the character used as the
57
+ # separator. If you're upgrading from FriendlyId 4, you may wish to replace this
58
+ # with two dashes.
59
+ #
60
+ # config.sequence_separator = '-'
61
+ #
62
+ # ## Tips and Tricks
63
+ #
64
+ # ### Controlling when slugs are generated
65
+ #
66
+ # As of FriendlyId 5.0, new slugs are generated only when the slug field is
67
+ # nil, but if you're using a column as your base method can change this
68
+ # behavior by overriding the `should_generate_new_friendly_id` method that
69
+ # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
70
+ # more like 4.0.
71
+ #
72
+ # config.use Module.new {
73
+ # def should_generate_new_friendly_id?
74
+ # slug.blank? || <your_column_name_here>_changed?
75
+ # end
76
+ # }
77
+ #
78
+ # FriendlyId uses Rails's `parameterize` method to generate slugs, but for
79
+ # languages that don't use the Roman alphabet, that's not usually sufficient.
80
+ # Here we use the Babosa library to transliterate Russian Cyrillic slugs to
81
+ # ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
82
+ #
83
+ # config.use Module.new {
84
+ # def normalize_friendly_id(text)
85
+ # text.to_slug.normalize! :transliterations => [:russian, :latin]
86
+ # end
87
+ # }
88
+ end
@@ -5,11 +5,17 @@ en:
5
5
 
6
6
  index:
7
7
  title: Home
8
+ sign_in_title: Please sign in
9
+ sign_in: Sign in
10
+ remember_me: Remember me
8
11
  submit: Submit
9
12
  new: New
10
13
  edit: Edit
11
14
  destroy: Destroy
12
15
  actions: Actions
16
+ coming_soon: Coming soon
17
+ back_to_top: Back to top
18
+ powered_by_home_page_software: Powered by %{link}.
13
19
 
14
20
  form:
15
21
  errors_count: '%{count} prohibited this object from being saved:'
@@ -0,0 +1,4 @@
1
+ en:
2
+ tags:
3
+ index:
4
+ title: Tags
data/config/routes.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  Rails.application.routes.draw do
2
- devise_for :users, controllers: { registrations: 'devise_extensions/registrations' }
2
+ devise_for :users, controllers: {
3
+ registrations: 'devise_extensions/registrations',
4
+ sessions: 'devise_extensions/sessions'
5
+ }
3
6
 
4
7
  resources :users, only: [:index, :edit, :update, :destroy]
5
8
 
@@ -39,6 +39,7 @@ class CreateInitialSchema < ActiveRecord::Migration
39
39
  t.timestamps
40
40
  end
41
41
 
42
+ add_index :users, :slug, unique: true
42
43
  add_index :users, :name, unique: true
43
44
  add_index :users, :email, unique: true
44
45
  add_index :users, :reset_password_token, unique: true
@@ -46,8 +47,6 @@ class CreateInitialSchema < ActiveRecord::Migration
46
47
  end
47
48
 
48
49
  def self.down
49
- # By default, we don't want to make any assumption about how to roll back a migration when your
50
- # model already existed. Please edit below which fields you would like to remove in this migration.
51
- raise ActiveRecord::IrreversibleMigration
50
+ drop_table :users
52
51
  end
53
52
  end
@@ -0,0 +1,15 @@
1
+ class CreateFriendlyIdSlugs < ActiveRecord::Migration
2
+ def change
3
+ create_table :friendly_id_slugs do |t|
4
+ t.string :slug, :null => false
5
+ t.integer :sluggable_id, :null => false
6
+ t.string :sluggable_type, :limit => 50
7
+ t.string :scope
8
+ t.datetime :created_at
9
+ end
10
+ add_index :friendly_id_slugs, :sluggable_id
11
+ add_index :friendly_id_slugs, [:slug, :sluggable_type]
12
+ add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true
13
+ add_index :friendly_id_slugs, :sluggable_type
14
+ end
15
+ end