diff --git a/Gemfile b/Gemfile index 5463bba4d37ef12c1681fbb237d4b409cdf310e7..37e070584e47dd9f39a88014f8928e76cc949338 100644 --- a/Gemfile +++ b/Gemfile @@ -35,30 +35,15 @@ gem 'orientdb4r' # web server gem 'puma' -gem 'rufus-scheduler' - -group :development, :test do - gem 'better_errors' - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' - - # 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 :test do - gem 'shoulda' - gem 'shoulda-callback-matchers', '~> 1.1.1' -end +# scheduler +gem 'whenever', :require => false # authentication gem 'devise' +# files +gem 'paperclip' + # enable login via rest gem 'devise_token_auth' gem 'rack-cors', require: 'rack/cors' @@ -85,13 +70,39 @@ gem 'chart-js-rails' #depoyment gem 'mina' +# management visual framework gem 'locastyle' + +# paginate results gem 'will_paginate', '~> 3.0.5' -# profilers +# evaluate source code gem 'rubycritic', require: false -gem 'rack-mini-profiler' -gem 'bullet' # docs gem 'rdoc' + +group :development, :test do + # profiler + gem 'rack-mini-profiler' + gem 'flamegraph' + # reduce queries - https://github.com/flyerhzm/bullet + gem 'bullet' + + gem 'better_errors' + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug' + + # 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 :test do + gem 'shoulda' + gem 'shoulda-callback-matchers', '~> 1.1.1' +end diff --git a/app/assets/images/missing.svg b/app/assets/images/missing.svg new file mode 100644 index 0000000000000000000000000000000000000000..39e55e773a922b5f1a24e0ad5acf76ad0f722223 --- /dev/null +++ b/app/assets/images/missing.svg @@ -0,0 +1,227 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + inkscape:export-ydpi="90.000000" + inkscape:export-xdpi="90.000000" + inkscape:export-filename="/home/jimmac/Desktop/wi-fi.png" + width="48px" + height="48px" + id="svg11300" + sodipodi:version="0.32" + inkscape:version="0.43+devel" + sodipodi:docbase="/home/tigert/cvs/freedesktop.org/tango-icon-theme/scalable/status" + sodipodi:docname="image-missing.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs3"> + <linearGradient + id="linearGradient3563"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop3565" /> + <stop + style="stop-color:#939393;stop-opacity:1;" + offset="1" + id="stop3567" /> + </linearGradient> + <linearGradient + id="linearGradient3555"> + <stop + style="stop-color:#f2f2f2;stop-opacity:1;" + offset="0" + id="stop3557" /> + <stop + style="stop-color:#d0d0d0;stop-opacity:1;" + offset="1" + id="stop3559" /> + </linearGradient> + <linearGradient + style="stroke-dasharray:none;stroke-miterlimit:4.0000000;stroke-width:1.2166667" + y2="36.0328" + x2="31.0813" + y1="3.7319" + x1="12.4873" + gradientUnits="userSpaceOnUse" + id="aigrd1"> + <stop + id="stop16177" + style="stop-color:#D2D2D2;stroke-dasharray:none;stroke-miterlimit:4.0000000;stroke-width:1.2166667" + offset="0" /> + <stop + id="stop16179" + style="stop-color:#EDEDED;stroke-dasharray:none;stroke-miterlimit:4.0000000;stroke-width:1.2166667" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#aigrd1" + id="linearGradient16280" + gradientUnits="userSpaceOnUse" + x1="12.4873" + y1="3.7319" + x2="31.0813" + y2="36.0328" + gradientTransform="matrix(1.211383,0.000000,0.000000,1.211383,-2.021433,0.189894)" /> + <linearGradient + inkscape:collect="always" + id="linearGradient12129"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop12131" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop12133" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient12129" + id="radialGradient12135" + cx="24.218407" + cy="41.636040" + fx="24.218407" + fy="41.636040" + r="22.097088" + gradientTransform="matrix(1.000000,0.000000,0.000000,0.184000,0.000000,33.97501)" + gradientUnits="userSpaceOnUse" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3555" + id="radialGradient3561" + cx="26.728037" + cy="38.34853" + fx="26.728037" + fy="38.34853" + r="17.926361" + gradientTransform="matrix(1.848501,-1.547102e-23,1.227926e-24,1.289078,-21.29931,-13.68176)" + gradientUnits="userSpaceOnUse" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3563" + id="linearGradient3569" + x1="28.107494" + y1="34.868584" + x2="22.169001" + y2="9.8661737" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(0.000000,0.883885)" /> + </defs> + <sodipodi:namedview + stroke="#cc0000" + fill="#cc0000" + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="0.25490196" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="5.6568542" + inkscape:cx="21.313886" + inkscape:cy="27.870334" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:grid-bbox="true" + inkscape:document-units="px" + inkscape:showpageshadow="false" + inkscape:window-width="770" + inkscape:window-height="630" + inkscape:window-x="180" + inkscape:window-y="85" /> + <metadata + id="metadata4"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:creator> + <cc:Agent> + <dc:title>Jakub Steiner</dc:title> + </cc:Agent> + </dc:creator> + <dc:source>http://jimmac.musichall.cz</dc:source> + <cc:license + rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" /> + <dc:title>Broken Image</dc:title> + <dc:subject> + <rdf:Bag> + <rdf:li>image</rdf:li> + <rdf:li>picture</rdf:li> + <rdf:li>photo</rdf:li> + <rdf:li>missing</rdf:li> + <rdf:li>broken</rdf:li> + <rdf:li>404</rdf:li> + </rdf:Bag> + </dc:subject> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/by-sa/2.0/"> + <cc:permits + rdf:resource="http://web.resource.org/cc/Reproduction" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/Distribution" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/Notice" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/Attribution" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/ShareAlike" /> + </cc:License> + </rdf:RDF> + </metadata> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <path + sodipodi:type="arc" + style="opacity:0.52763821;color:#000000;fill:url(#radialGradient12135);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.61658032;visibility:visible;display:block" + id="path12127" + sodipodi:cx="24.218407" + sodipodi:cy="41.63604" + sodipodi:rx="22.097088" + sodipodi:ry="4.0658641" + d="M 46.315495 41.63604 A 22.097088 4.0658641 0 1 1 2.1213188,41.63604 A 22.097088 4.0658641 0 1 1 46.315495 41.63604 z" + transform="translate(0.176777,0.900834)" /> + <path + id="path16181" + d="M 45.343675,39.903974 C 45.343675,41.842189 43.768877,43.416987 41.830663,43.416987 L 6.3371177,43.416987 C 4.3989037,43.416987 2.8241047,41.842189 2.8241047,39.903974 L 2.8241047,7.0947821 C 2.8241047,5.1565681 4.3989037,3.581769 6.3371177,3.581769 L 41.830663,3.581769 C 43.768877,3.581769 45.343675,5.1565681 45.343675,7.0947821 L 45.343675,39.903974 L 45.343675,39.903974 z " + style="fill:url(#linearGradient16280);fill-rule:nonzero;stroke:#646464;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cccccccccc" /> + <path + style="fill:url(#radialGradient3561);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3569);stroke-width:0.99999923;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.61658032" + d="M 41.467991,35.25247 L 6.6152692,35.25247 L 6.6152692,11.250058 L 41.467991,11.250058 L 41.467991,35.25247 L 41.467991,35.25247 z " + id="path12125" + sodipodi:nodetypes="cccccc" /> + <path + style="fill:none;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.00000012;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.86010359" + d="M 44.480104,39.32848 C 44.480104,41.187964 43.499604,42.345241 41.640121,42.345241 L 6.6160507,42.345241 C 4.7565677,42.345241 3.6876787,41.276353 3.6876787,39.416869 L 3.6876787,7.5970548 C 3.6876787,5.737571 5.1985087,4.403517 7.0579927,4.403517 L 41.198179,4.403517 C 43.057662,4.403517 44.480104,5.737571 44.480104,7.5970548 L 44.480104,38.974927 L 44.480104,39.32848 z " + id="path11975" + sodipodi:nodetypes="cccccccccc" /> + <g + id="g3551" + transform="matrix(0.772431,0.000000,0.000000,0.772431,10.05699,9.902145)"> + <path + d="M 11.318692,9.2240568 C 16.641997,14.693047 22.769247,19.123651 29.210664,22.931105 L 27.441568,24.159843 C 21.101863,20.04489 15.052508,15.498993 9.1840818,10.652117 L 11.318692,9.2240568 z " + id="path2565" + style="opacity:1;color:#000000;fill:#cc0000;fill-opacity:1;fill-rule:nonzero;stroke:#cc0000;stroke-width:2.58922911;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> + <path + d="M 26.73892,8.9210568 C 21.867631,15.95255 15.247359,21.081199 7.9065151,25.28163 L 10.087564,23.520856 C 8.7241111,24.379297 25.574485,11.804168 23.852075,10.207903 L 26.73892,8.9210568 z " + id="path2575" + style="opacity:1;color:#000000;fill:#cc0000;fill-opacity:1;fill-rule:nonzero;stroke:#cc0000;stroke-width:2.58922839;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> + </g> + </g> +</svg> diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 0855037f3832576e89ea2d693856b817c4808a6f..dc5d2ac45cbb013fb36220d27526bca43e2e8f10 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -29,6 +29,10 @@ body { font-family: 'Roboto', "Helvetica Neue", Helvetica, Arial, sans-serif; } +a, a:focus, a:hover { + color: #000; +} + //// HEADER header { border: 0; @@ -123,10 +127,16 @@ header { } // user info .status-text { - margin-top: 10px; + margin-top: 20px; font-size: 20px; text-align: right; + .circular-image { + width: 60px; + height: 60px; + border-radius: 50%; + } + .media-heading { font-size: 32px; a { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c2a66dab49848d4295a9fb227caffac4445c89bb..374155aaae133f416c4eb513e34151f23766d8bd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,7 +11,17 @@ class ApplicationController < ActionController::Base protected def configure_permitted_parameters - devise_parameter_sanitizer.for(:sign_up) << :name + registration_params = [:name, :email, :avatar, :password, :password_confirmation] + + if params[:action] == 'update' + devise_parameter_sanitizer.for(:account_update) { + |u| u.permit(registration_params << :current_password) + } + elsif params[:action] == 'create' + devise_parameter_sanitizer.for(:sign_up) { + |u| u.permit(registration_params) + } + end end def dspace_service diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..96c21aa17d468af0acb632a45c2cbc9eb9de3bfc --- /dev/null +++ b/app/controllers/institutions_controller.rb @@ -0,0 +1,77 @@ +class InstitutionsController < ApplicationController + before_action :set_institution, only: [:show, :edit, :update, :destroy, :like] + + # GET /institutions + # GET /institutions.json + def index + @institutions = institution_repository.all + end + + # GET /institutions/1 + # GET /institutions/1.json + def show + end + + # GET /institutions/new + def new + @institution = Institution.new + end + + # GET /institutions/1/edit + def edit + end + + # POST /institutions + # POST /institutions.json + def create + @institution = Institution.new(institution_params) + + respond_to do |format| + if institution_repository.save @institution + format.html { redirect_to @institution, notice: 'Institution was successfully created.' } + else + format.html { render :new } + end + end + end + + # PATCH/PUT /institutions/1 + # PATCH/PUT /institutions/1.json + def update + respond_to do |format| + if institution_repository.update(institution_params) + format.html { redirect_to @learning_object, notice: 'Institution was successfully updated.' } + else + format.html { render :edit } + end + end + end + + # DELETE /institutions/1 + # DELETE /institutions/1.json + def destroy + institution_repository.destroy @institution + + respond_to do |format| + format.html { redirect_to institutions_url, notice: 'Learning object was successfully destroyed.' } + end + end + + + + private + + def set_institution + @institution = institution_repository.find("##{params[:id]}") + end + + def institution_repository + repository.for(:institution) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def institution_params + params[:institution_object] + end + +end diff --git a/app/models/user.rb b/app/models/user.rb index ce7b5788f05d95eb4b576d368edad4719320541e..28100ca583e944ea07f031fab91efee58583551d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,4 +25,7 @@ class User < ActiveRecord::Base has_and_belongs_to_many :roles after_create SyncUserRepositoryService.new after_destroy SyncUserRepositoryService.new + + has_attached_file :avatar, styles: { medium: "300x300>", thumb: "60x60>" }, default_url: ActionController::Base.helpers.asset_path('missing.svg') + validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/ end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 51ee35d468d244240877322f4c038e7af2f87448..9a894469bc0691b04f35cfa7aa4d622dc030f0fa 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,6 +1,6 @@ <h2>Edit <%= resource_name.to_s.humanize %></h2> -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, multipart: true}) do |f| %> <%= devise_error_messages! %> <div class="field"> @@ -13,6 +13,11 @@ <%= f.email_field :email, autofocus: true %> </div> + <div class="field"> + <%= f.label :avatar %><br/> + <%= f.file_field :avatar %> + </div> + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div> <% end %> diff --git a/app/views/shared/application/_header.html.erb b/app/views/shared/application/_header.html.erb index 94a1b0abce80aa37a1db5a9e6918e14bc970ec74..515a4df0f24c2a7dfa30fcec884e5f4142447a49 100644 --- a/app/views/shared/application/_header.html.erb +++ b/app/views/shared/application/_header.html.erb @@ -13,13 +13,13 @@ <div class="search-bar"> <div class="container"> <div class="row"> - <div class="col-md-2 logo-text"> + <div class="col-md-3 logo-text"> <%= link_to root_path do %> CONTEÚDO<br>EDUCACIONAL <% end %> </div> - <div class="col-md-8"> + <div class="col-md-6"> <div class="search-accessibility"> <%= image_tag 'fonte_mais.png', onclick: 'resizeText(1)' %> <%= image_tag 'fonte_inicial.png', onclick: 'resizeText(0)' %> @@ -35,23 +35,23 @@ </div> </div> </form> - <%= link_to 'busca avançada', '#', class: 'search-label' %> + <%= link_to 'busca avançada', search_path, class: 'search-label' %> </div> </div> - <div class="col-md-2 status-text"> + <div class="col-md-3 status-text"> <% if user_signed_in? %> - <li class="media"> + <div class="media"> <div class="media-body"> <h4 class="media-heading"><%= link_to current_user.name, edit_user_registration_path %></h4> <%= link_to 'sair', destroy_user_session_path, method: 'delete', class: "quit-link" %> </div> <div class="media-right"> <a href="#"> - <img class="media-object" src="/" alt="Foto do usuário"> + <img class="circular-image" src="<%= current_user.avatar.url(:thumb) %>" alt="Foto do usuário"/> </a> </div> - </li> + </div> <% else %> <div class="media"> <div class="media-body"> diff --git a/config/environments/development.rb b/config/environments/development.rb index 5fafdd184b3f3b5e96ff55a3a0fabc29f87942b3..eb3772c3a0867beabd00a672cf5c425b64731fa7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,6 +1,18 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + ## Bullet gem config + config.after_initialize do + Bullet.enable = true + Bullet.alert = true + Bullet.bullet_logger = true + Bullet.console = true + Bullet.rails_logger = true + Bullet.add_footer = true + #Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ] + #Bullet.slack = { webhook_url: 'http://some.slack.url', foo: 'bar' } + end + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. diff --git a/config/initializers/task_scheduler.rb b/config/initializers/task_scheduler.rb deleted file mode 100644 index 248977184633cc5a31978a46da6670148df4b050..0000000000000000000000000000000000000000 --- a/config/initializers/task_scheduler.rb +++ /dev/null @@ -1,4 +0,0 @@ -scheduler = Rufus::Scheduler.new -scheduler.every '5m' do - system('rake mainPage:highlights') - end diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 0000000000000000000000000000000000000000..a56f2cde9352830e293753c922ada6b3766b290f --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,24 @@ +# Use this file to easily define all of your cron jobs. +# +# It's helpful, but not entirely necessary to understand cron before proceeding. +# http://en.wikipedia.org/wiki/Cron + +# Example: +# +# set :output, "/path/to/my/cron_log.log" +# +# every 2.hours do +# command "/usr/bin/some_great_command" +# runner "MyModel.some_method" +# rake "some:great:rake:task" +# end +# +# every 4.days do +# runner "AnotherModel.prune_old_records" +# end + +# Learn more: http://github.com/javan/whenever + +every 5.minutes do + rake 'mainPage:highlights' +end diff --git a/db/migrate/20150921132848_add_attachment_avatar_to_users.rb b/db/migrate/20150921132848_add_attachment_avatar_to_users.rb new file mode 100644 index 0000000000000000000000000000000000000000..1d87ba81ad4a303b20ad6e6fdc95c910aa43edb7 --- /dev/null +++ b/db/migrate/20150921132848_add_attachment_avatar_to_users.rb @@ -0,0 +1,11 @@ +class AddAttachmentAvatarToUsers < ActiveRecord::Migration + def self.up + change_table :users do |t| + t.attachment :avatar + end + end + + def self.down + remove_attachment :users, :avatar + end +end