diff --git a/Gemfile b/Gemfile index 19a9ff0..9c4fcea 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' ruby '2.1.2' -gem 'rails', '4.2.0.beta1' +gem 'rails', '4.2.0' gem 'cancan' #gem 'devise' # https://github.com/plataformatec/devise/pull/3153 @@ -22,9 +22,7 @@ gem 'therubyracer', platforms: :ruby gem 'jquery-rails' gem 'turbolinks' gem 'bootstrap-wysihtml5-rails' -#gem 'bootstrap-sass', '>= 3.2.0.1' -# Temporary fix -gem 'bootstrap-sass', github: 'everaldo/bootstrap-sass' +gem 'bootstrap-sass', '>= 3.2.0.2' gem 'html2haml' gem 'quiet_assets' gem 'rails_layout' @@ -42,9 +40,6 @@ gem 'sdoc', '~> 0.4.0', group: :doc # Use Rails Html Sanitizer for HTML sanitization gem 'rails-html-sanitizer', '~> 1.0' -gem 'mina' -gem 'mina-scp', require: false - group :development, :test do # Call 'debugger' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index e5e5bbe..43f265e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,3 @@ -GIT - remote: git://github.com/everaldo/bootstrap-sass.git - revision: 21bff940bec205d641a818e08fce699810277d42 - specs: - bootstrap-sass (3.2.0.1) - sass (~> 3.2) - GIT remote: git://github.com/mongoid/mongoid.git revision: 4e3b39e9bbcf1b36d0472c6b09f8f394c55065f4 @@ -31,41 +24,43 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.0.beta1) - actionpack (= 4.2.0.beta1) - actionview (= 4.2.0.beta1) + actionmailer (4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.2) - actionpack (4.2.0.beta1) - actionview (= 4.2.0.beta1) - activesupport (= 4.2.0.beta1) - rack (~> 1.6.0.beta) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) rack-test (~> 0.6.2) - rails-deprecated_sanitizer (~> 1.0, >= 1.0.2) - rails-dom-testing (~> 1.0, >= 1.0.2) - actionview (4.2.0.beta1) - activesupport (= 4.2.0.beta1) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) erubis (~> 2.7.0) - rails-deprecated_sanitizer (~> 1.0, >= 1.0.2) - rails-dom-testing (~> 1.0, >= 1.0.2) - activejob (4.2.0.beta1) - globalid (>= 0.2.3) - activemodel (4.2.0.beta1) - activesupport (= 4.2.0.beta1) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.0) + activesupport (= 4.2.0) + globalid (>= 0.3.0) + activemodel (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) - activerecord (4.2.0.beta1) - activemodel (= 4.2.0.beta1) - activesupport (= 4.2.0.beta1) - arel (>= 6.0.0.beta1, < 6.1) - activesupport (4.2.0.beta1) - i18n (>= 0.7.0.beta1, < 0.8) + activerecord (4.2.0) + activemodel (= 4.2.0) + activesupport (= 4.2.0) + arel (~> 6.0) + activesupport (4.2.0) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.6) - arel (6.0.0.beta1) + arel (6.0.0) bcrypt (3.1.7) better_errors (2.0.0) coderay (>= 1.0.0) @@ -73,6 +68,8 @@ GEM rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bootstrap-sass (3.2.0.2) + sass (~> 3.2) bootstrap-wysihtml5-rails (0.3.2.100) railties (>= 3.0) bson (2.3.0) @@ -132,7 +129,7 @@ GEM rails (>= 3, < 5) formatador (0.2.5) geocoder (1.2.4) - globalid (0.2.3) + globalid (0.3.0) activesupport (>= 4.1.0) guard (2.6.1) formatador (>= 0.2.4) @@ -157,7 +154,7 @@ GEM haml (>= 4.0.0.rc.1) hpricot (~> 0.8.6) ruby_parser (~> 3.1.1) - i18n (0.7.0.beta1) + i18n (0.7.0) jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) @@ -176,16 +173,16 @@ GEM loofah (2.0.1) nokogiri (>= 1.5.9) lumberjack (1.0.9) - mail (2.6.1) + mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) - mime-types (2.3) + mime-types (2.4.3) mina (0.3.0) open4 rake mina-scp (0.1.1) - mini_portile (0.6.0) - minitest (5.4.1) + mini_portile (0.6.2) + minitest (5.5.0) mongoid-grid_fs (2.1.0) mime-types (>= 1.0, < 3.0) mongoid (>= 3.0, < 5.0) @@ -197,8 +194,8 @@ GEM connection_pool (~> 2.0) optionable (~> 0.2.0) multi_json (1.10.1) - nokogiri (1.6.3.1) - mini_portile (= 0.6.0) + nokogiri (1.6.5) + mini_portile (~> 0.6.0) open4 (1.3.4) optionable (0.2.0) origin (2.1.1) @@ -214,36 +211,36 @@ GEM pry (>= 0.9.10) quiet_assets (1.0.3) railties (>= 3.1, < 5.0) - rack (1.6.0.beta) + rack (1.6.0) rack-test (0.6.2) rack (>= 1.0) - rails (4.2.0.beta1) - actionmailer (= 4.2.0.beta1) - actionpack (= 4.2.0.beta1) - actionview (= 4.2.0.beta1) - activejob (= 4.2.0.beta1) - activemodel (= 4.2.0.beta1) - activerecord (= 4.2.0.beta1) - activesupport (= 4.2.0.beta1) + rails (4.2.0) + actionmailer (= 4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + activemodel (= 4.2.0) + activerecord (= 4.2.0) + activesupport (= 4.2.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.0.beta1) - sprockets-rails (~> 3.0.0.beta1) - rails-deprecated_sanitizer (1.0.2) + railties (= 4.2.0) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.2) - activesupport + rails-dom-testing (1.0.5) + activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.0) + rails-html-sanitizer (1.0.1) loofah (~> 2.0) rails_layout (1.0.21) - railties (4.2.0.beta1) - actionpack (= 4.2.0.beta1) - activesupport (= 4.2.0.beta1) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) - rake (10.3.2) + rake (10.4.2) rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) @@ -296,15 +293,15 @@ GEM activemodel (~> 4.0) slop (3.6.0) spring (1.1.3) - sprockets (2.12.1) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (3.0.0.beta1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (~> 2.8) + sprockets-rails (2.2.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref @@ -347,7 +344,7 @@ PLATFORMS DEPENDENCIES better_errors binding_of_caller - bootstrap-sass! + bootstrap-sass (>= 3.2.0.2) bootstrap-wysihtml5-rails byebug cancan @@ -372,7 +369,7 @@ DEPENDENCIES pry-byebug pry-rails quiet_assets - rails (= 4.2.0.beta1) + rails (= 4.2.0) rails-html-sanitizer (~> 1.0) rails_layout rmagick diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index cdc4c93..3b43f93 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -69,6 +69,6 @@ def set_category # Never trust parameters from the scary internet, only allow the white list through. def category_params - params.require(:category).permit(:category_name) + params.require(:category).permit(:name) end end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 2f51bfd..d70b0e3 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,4 +1,5 @@ class Admin::DashboardController < Admin::AdminController def index + @categories = Category.all end end diff --git a/app/helpers/show_attributes_helper.rb b/app/helpers/show_attributes_helper.rb new file mode 100644 index 0000000..eeecdd9 --- /dev/null +++ b/app/helpers/show_attributes_helper.rb @@ -0,0 +1,10 @@ +module ShowAttributesHelper + def show_attributes(resource, *attributes) + render partial: 'show_attributes', locals: {resource: resource, attributes: attributes} + end + + def show_attribute(resource, attribute) + render partial: 'show_attribute', locals: {resource: resource, attribute: attribute} + end +end + diff --git a/app/helpers/translations_helper.rb b/app/helpers/translations_helper.rb new file mode 100644 index 0000000..413772e --- /dev/null +++ b/app/helpers/translations_helper.rb @@ -0,0 +1,5 @@ +module TranslationsHelper + def attribute_name_for(resource_class, attribute) + resource_class.human_attribute_name attribute + end +end diff --git a/app/models/category.rb b/app/models/category.rb index cf499db..ec5c147 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -3,7 +3,7 @@ class Category include Mongoid::Timestamps #Validations - validates :name, presence: true + validates :name, presence: true, uniqueness: true #Relationships has_many :jobs diff --git a/app/views/admin/categories/_form.html.haml b/app/views/admin/categories/_form.html.haml index 4b2a489..9eda23a 100644 --- a/app/views/admin/categories/_form.html.haml +++ b/app/views/admin/categories/_form.html.haml @@ -1,6 +1,6 @@ = simple_form_for [:admin, @category] do |f| = f.error_notification .form-inputs - = f.input :category_name + = f.input :name .form-actions = f.submit 'Save' diff --git a/app/views/admin/categories/edit.html.haml b/app/views/admin/categories/edit.html.haml index 1cbabae..4a98498 100644 --- a/app/views/admin/categories/edit.html.haml +++ b/app/views/admin/categories/edit.html.haml @@ -1,7 +1,7 @@ -%h1 Editing category +%h1= t('admin.categories.edit.title') = render 'form' -= link_to 'Show', [:admin,@category] += link_to t('actions.show'), [:admin,@category] \| -= link_to 'Back', admin_categories_path += link_to t('actions.back'), admin_categories_path diff --git a/app/views/admin/categories/index.html.haml b/app/views/admin/categories/index.html.haml index db7cf68..3463280 100644 --- a/app/views/admin/categories/index.html.haml +++ b/app/views/admin/categories/index.html.haml @@ -1,24 +1,22 @@ .page-header - %h1 Listing Jobs Categories + %h1= t('admin.categories.title') %table.table.table-striped %tr - %th Category Id - %th Category Name - %th Created At - %th Actions + %th= attribute_name_for Category, :name + %th= attribute_name_for Category, :created_at + %th= t('actions.title') - @categories.each do |category| %tr - %td= category.id - %td= category.category_name + %td= category.name %td= category.created_at %td .btn-group.btn-group-sm - = link_to 'Show', [:admin,category], class: 'btn btn-default' - = link_to 'Edit', edit_admin_category_path(category), class: 'btn btn-default' - = link_to 'Destroy', [:admin,category], :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-default' + = link_to t('actions.show'), [:admin,category], class: 'btn btn-default' + = link_to t('actions.edit'), edit_admin_category_path(category), class: 'btn btn-default' + = link_to t('actions.destroy'), [:admin,category], :method => :delete, :data => { :confirm => t('actions.confirm_destroy') }, class: 'btn btn-default' %br -= link_to 'New Jobs category', new_admin_category_path, class: 'btn btn-primary' += link_to t('admin.categories.new'), new_admin_category_path, class: 'btn btn-primary' diff --git a/app/views/admin/categories/new.html.haml b/app/views/admin/categories/new.html.haml index e807df7..b594b87 100644 --- a/app/views/admin/categories/new.html.haml +++ b/app/views/admin/categories/new.html.haml @@ -2,4 +2,4 @@ = render 'form' -= link_to 'Back', admin_jobs_categories_path += link_to 'Back', admin_categories_path diff --git a/app/views/admin/categories/show.html.haml b/app/views/admin/categories/show.html.haml index 4631d38..a5ca80c 100644 --- a/app/views/admin/categories/show.html.haml +++ b/app/views/admin/categories/show.html.haml @@ -1,6 +1,9 @@ %p#notice= notice +%h1= t('actions.show') -= link_to 'Edit', edit_admin_jobs_category_path(@jobs_category) += show_attributes @category, :name, :created_at + += link_to t('actions.edit'), edit_admin_category_path(@category) \| -= link_to 'Back', admin_jobs_categories_path += link_to t('actions.back'), admin_categories_path diff --git a/app/views/admin/dashboard/_category.html.haml b/app/views/admin/dashboard/_category.html.haml new file mode 100644 index 0000000..b4fe7fc --- /dev/null +++ b/app/views/admin/dashboard/_category.html.haml @@ -0,0 +1 @@ +%li.list-group-item= category.name diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index c3266e6..239377f 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -1,13 +1,15 @@ .page-header - %h1 Dashboard + %h1= t('admin.dashboard.title') .col-lg-6 .panel.panel-default .panel-heading - %h3.panel-title Jobs + %h3.panel-title= t('admin.dashboard.jobs') .panel-body .col-lg-6 .panel.panel-default .panel-heading - %h3.panel-title Jobs Categories + %h3.panel-title= t('admin.dashboard.categories') .panel-body + %ul + = render partial: 'category', collection: @categories diff --git a/app/views/application/_show_attribute.html.haml b/app/views/application/_show_attribute.html.haml new file mode 100644 index 0000000..f87eae5 --- /dev/null +++ b/app/views/application/_show_attribute.html.haml @@ -0,0 +1,3 @@ +%p + %b= attribute_name_for resource.class, attribute + = resource.send attribute diff --git a/app/views/application/_show_attributes.html.haml b/app/views/application/_show_attributes.html.haml new file mode 100644 index 0000000..d03732c --- /dev/null +++ b/app/views/application/_show_attributes.html.haml @@ -0,0 +1,2 @@ +- attributes.each do |attribute| + = show_attribute(resource, attribute) diff --git a/app/views/layouts/admin/_navigation.html.haml b/app/views/layouts/admin/_navigation.html.haml index a87a6ac..f3520b4 100644 --- a/app/views/layouts/admin/_navigation.html.haml +++ b/app/views/layouts/admin/_navigation.html.haml @@ -7,7 +7,7 @@ %span.icon-bar %span.icon-bar %span.icon-bar - = link_to 'TecnoFreela', admin_root_path, class: 'navbar-brand' + = link_to t('site.title'), admin_root_path, class: 'navbar-brand' .collapse.navbar-collapse %ul.nav.navbar-nav = render 'layouts/admin/navigation_links' diff --git a/app/views/layouts/admin/_navigation_links.html.erb b/app/views/layouts/admin/_navigation_links.html.erb deleted file mode 100644 index 3ff9be1..0000000 --- a/app/views/layouts/admin/_navigation_links.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -
  • <%= link_to "Dashboard", admin_root_path %>
  • -
  • <%= link_to "Jobs", admin_jobs_path %>
  • -
  • <%= link_to "Jobs Categories", admin_categories_path %>
  • - diff --git a/app/views/layouts/admin/_navigation_links.html.haml b/app/views/layouts/admin/_navigation_links.html.haml index 571ecf8..677fe2d 100644 --- a/app/views/layouts/admin/_navigation_links.html.haml +++ b/app/views/layouts/admin/_navigation_links.html.haml @@ -1,7 +1,7 @@ %li - = link_to "Dashboard", admin_root_path + = link_to t('admin.dashboard.navigation_links.root'), admin_root_path %li - = link_to "Jobs", admin_jobs_path + = link_to t('admin.dashboard.navigation_links.jobs'), admin_jobs_path %li - = link_to "Jobs Categories", admin_categories_path + = link_to t('admin.dashboard.navigation_links.categories'), admin_categories_path diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458..f9fb404 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,6 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.action_dispatch.cookies_serializer = :json + +## Commented out the line below, due to a bug with Mongoid +## https://github.com/plataformatec/devise/pull/2882 +#Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb new file mode 100644 index 0000000..5118083 --- /dev/null +++ b/config/initializers/time_formats.rb @@ -0,0 +1 @@ +Time::DATE_FORMATS[:default] = '%d/%m/%Y %H:%M' diff --git a/config/locales/pt-BR/models/category.yml b/config/locales/pt-BR/models/category.yml new file mode 100644 index 0000000..192b5e6 --- /dev/null +++ b/config/locales/pt-BR/models/category.yml @@ -0,0 +1,8 @@ +pt-BR: + mongoid: + models: + category: Categoria + attributes: + category: + name: Nome + created_at: Criado em diff --git a/config/locales/pt-BR/views/admin/categories/edit.yml b/config/locales/pt-BR/views/admin/categories/edit.yml new file mode 100644 index 0000000..c671970 --- /dev/null +++ b/config/locales/pt-BR/views/admin/categories/edit.yml @@ -0,0 +1,6 @@ +pt-BR: + admin: + categories: + edit: + title: Editando categoria + diff --git a/config/locales/pt-BR/views/admin/categories/index.yml b/config/locales/pt-BR/views/admin/categories/index.yml new file mode 100644 index 0000000..5955c10 --- /dev/null +++ b/config/locales/pt-BR/views/admin/categories/index.yml @@ -0,0 +1,5 @@ +pt-BR: + admin: + categories: + title: Categorias + new: Nova categoria diff --git a/config/locales/pt-BR/views/admin/dashboard/index.yml b/config/locales/pt-BR/views/admin/dashboard/index.yml new file mode 100644 index 0000000..2d0d6d0 --- /dev/null +++ b/config/locales/pt-BR/views/admin/dashboard/index.yml @@ -0,0 +1,6 @@ +pt-BR: + admin: + dashboard: + title: Painel + jobs: Anúncios + categories: Categorias diff --git a/config/locales/pt-BR/views/admin/dashboard/navigation_links.yml b/config/locales/pt-BR/views/admin/dashboard/navigation_links.yml new file mode 100644 index 0000000..92f0e92 --- /dev/null +++ b/config/locales/pt-BR/views/admin/dashboard/navigation_links.yml @@ -0,0 +1,8 @@ +pt-BR: + admin: + dashboard: + navigation_links: + root: Painel + jobs: Anúncios + categories: Categorias + diff --git a/config/locales/pt-BR/views/site.yml b/config/locales/pt-BR/views/site.yml new file mode 100644 index 0000000..92f4a5b --- /dev/null +++ b/config/locales/pt-BR/views/site.yml @@ -0,0 +1,11 @@ +pt-BR: + site: + title: 'TecnoFreela' + actions: + title: Ações + show: Detalhes + edit: Editar + destroy: Remover + confirm_destroy: Tem certeza? + back: Voltar +