diff --git a/Gemfile b/Gemfile index 37e070584e47dd9f39a88014f8928e76cc949338..43a380a159c7075835da3bd72b1430ea344b9545 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,7 @@ gem 'rubycritic', require: false # docs gem 'rdoc' +gem 'stackprof' group :development, :test do # profiler @@ -100,9 +101,24 @@ group :development, :test do gem 'spring' gem 'sqlite3' + + #JavaScript runtime + gem 'execjs' + gem 'therubyracer' + end group :test do gem 'shoulda' gem 'shoulda-callback-matchers', '~> 1.1.1' end + +gem 'streamio-ffmpeg', '~> 1.0.0' + +# sidekiq +gem 'sidekiq' +gem 'sinatra', require: false +gem 'slim' + +# CUrl +gem 'curb', '~> 0.8.8' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000000000000000000000000000000000..cea3c858ee916e8157c41c1f6daa194ad48e8ca2 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,351 @@ +GEM + remote: https://rubygems.org/ + specs: + abstract_type (0.0.7) + 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.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) + rack-test (~> 0.6.2) + 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-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) + 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.3, >= 0.3.4) + tzinfo (~> 1.1) + adamantium (0.2.0) + ice_nine (~> 0.11.0) + memoizable (~> 0.4.0) + arel (6.0.3) + ast (2.1.0) + autoprefixer-rails (6.0.3) + execjs + json + axiom-types (0.1.1) + descendants_tracker (~> 0.0.4) + ice_nine (~> 0.11.0) + thread_safe (~> 0.3, >= 0.3.1) + bcrypt (3.1.10) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + bootstrap-sass (3.3.5.1) + autoprefixer-rails (>= 5.0.0.1) + sass (>= 3.3.0) + builder (3.2.2) + bullet (4.14.7) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.9.0) + byebug (6.0.2) + chart-js-rails (0.0.9) + railties (> 3.1) + chronic (0.10.2) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.7) + climate_control (>= 0.0.3, < 1.0) + coderay (1.1.0) + coercible (1.0.0) + descendants_tracker (~> 0.0.1) + coffee-rails (4.1.0) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.9.1.1) + concord (0.1.5) + adamantium (~> 0.2.0) + equalizer (~> 0.0.9) + curb (0.8.8) + debug_inspector (0.0.2) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) + devise (3.5.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) + devise_token_auth (0.1.34) + devise (= 3.5.1) + rails (~> 4.2) + diff-lcs (1.2.5) + domain_name (0.5.24) + unf (>= 0.0.5, < 1.0.0) + dspace_rest_client (1.1.2) + curb (~> 0.8.6) + rest-client (>= 1.7, < 2) + equalizer (0.0.11) + erubis (2.7.0) + execjs (2.6.0) + fast_stack (0.1.0) + rake + rake-compiler + flamegraph (0.1.0) + fast_stack + flay (2.4.0) + ruby_parser (~> 3.0) + sexp_processor (~> 4.0) + flog (4.2.1) + ruby_parser (~> 3.1, > 3.1.0) + sexp_processor (~> 4.4) + globalid (0.3.6) + activesupport (>= 4.1.0) + gruff (0.6.0) + rmagick (>= 2.13.4) + http-cookie (1.0.2) + domain_name (~> 0.5) + i18n (0.7.0) + ice_nine (0.11.1) + jbuilder (2.3.1) + activesupport (>= 3.0.0, < 5) + multi_json (~> 1.2) + jquery-rails (4.0.5) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks + json (1.8.3) + libv8 (3.16.14.11) + locastyle (0.0.1) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + memoizable (0.4.2) + thread_safe (~> 0.3, >= 0.3.1) + mime-types (2.6.2) + mimemagic (0.3.0) + mina (0.3.7) + open4 (~> 1.3.4) + rake + mini_portile (0.6.2) + minitest (5.8.1) + multi_json (1.11.2) + netrc (0.10.3) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + open4 (1.3.4) + orientdb4r (0.5.1) + rest-client (~> 1.7) + orm_adapter (0.5.0) + paperclip (4.3.1) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + cocaine (~> 0.5.5) + mime-types + mimemagic (= 0.3.0) + parser (2.2.2.6) + ast (>= 1.1, < 3.0) + pg (0.18.3) + procto (0.0.2) + puma (2.14.0) + rack (1.6.4) + rack-cors (0.4.0) + rack-mini-profiler (0.9.7) + rack (>= 1.1.3) + rack-test (0.6.3) + rack (>= 1.0) + 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) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rainbow (2.0.0) + rake (10.4.2) + rake-compiler (0.9.5) + rake + rdoc (4.2.0) + reek (1.6.5) + parser (~> 2.2.0.pre.7) + rainbow (>= 1.99, < 3.0) + unparser (~> 0.2.2) + ref (2.0.0) + responders (2.1.0) + railties (>= 4.2.0, < 5) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + rmagick (2.15.4) + rsolr (1.0.12) + builder (>= 2.1.2) + ruby_parser (3.7.1) + sexp_processor (~> 4.1) + rubycritic (1.4.0) + flay (= 2.4.0) + flog (= 4.2.1) + parser (>= 2.2.0, < 3.0) + reek (= 1.6.5) + virtus (~> 1.0) + sass (3.4.18) + sass-rails (5.0.4) + railties (>= 4.0.0, < 5.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) + select2-rails (4.0.0) + thor (~> 0.14) + sexp_processor (4.6.0) + shoulda (3.5.0) + shoulda-context (~> 1.0, >= 1.0.1) + shoulda-matchers (>= 1.4.1, < 3.0) + shoulda-callback-matchers (1.1.3) + activesupport (>= 3) + shoulda-context (1.2.1) + shoulda-matchers (2.8.0) + activesupport (>= 3.0.0) + spring (1.4.0) + sprockets (3.3.5) + rack (> 1, < 3) + sprockets-rails (2.3.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.10) + stackprof (0.2.7) + therubyracer (0.12.2) + libv8 (~> 3.16.14.0) + ref + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.1) + turbolinks (2.5.3) + coffee-rails + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.7.2) + execjs (>= 0.3.0) + json (>= 1.8.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) + uniform_notifier (1.9.0) + unparser (0.2.4) + abstract_type (~> 0.0.7) + adamantium (~> 0.2.0) + concord (~> 0.1.5) + diff-lcs (~> 1.2.5) + equalizer (~> 0.0.9) + parser (~> 2.2.2) + procto (~> 0.0.2) + virtus (1.0.5) + axiom-types (~> 0.1) + coercible (~> 1.0) + descendants_tracker (~> 0.0, >= 0.0.3) + equalizer (~> 0.0, >= 0.0.9) + warden (1.2.3) + rack (>= 1.0) + web-console (2.2.1) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) + whenever (0.9.4) + chronic (>= 0.6.3) + will_paginate (3.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + bcrypt (~> 3.1.7) + better_errors + bootstrap-sass + bullet + byebug + chart-js-rails + coffee-rails (~> 4.1.0) + devise + devise_token_auth + dspace_rest_client (~> 1.1.0) + execjs + flamegraph + gruff + jbuilder (~> 2.0) + jquery-rails + jquery-turbolinks + locastyle + mina + orientdb4r + paperclip + pg + puma + rack-cors + rack-mini-profiler + rails (= 4.2.0) + rdoc + rmagick + rsolr (~> 1.0.12) + rubycritic + sass-rails (~> 5.0) + sdoc (~> 0.4.0) + select2-rails + shoulda + shoulda-callback-matchers (~> 1.1.1) + spring + sqlite3 + stackprof + therubyracer + turbolinks + uglifier (>= 1.3.0) + web-console (~> 2.0) + whenever + will_paginate (~> 3.0.5) + +BUNDLED WITH + 1.10.6 diff --git a/app/assets/images/icons/collection-add.png b/app/assets/images/icons/collection-add.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa684519e819dd3fe909bce96375fad0b335193 Binary files /dev/null and b/app/assets/images/icons/collection-add.png differ diff --git a/app/assets/images/icons/collection-download.png b/app/assets/images/icons/collection-download.png new file mode 100644 index 0000000000000000000000000000000000000000..ad972bdd8a05349a39e45731032a2e14a7eb496e Binary files /dev/null and b/app/assets/images/icons/collection-download.png differ diff --git a/app/assets/images/icons/collection-fast.png b/app/assets/images/icons/collection-fast.png new file mode 100644 index 0000000000000000000000000000000000000000..f6ab41783c1e3c7c4e2191d3a35e5c7e2b79d017 Binary files /dev/null and b/app/assets/images/icons/collection-fast.png differ diff --git a/app/assets/images/icons/collection-items.png b/app/assets/images/icons/collection-items.png new file mode 100644 index 0000000000000000000000000000000000000000..22190a91f0866488651423c67da56d54d411910f Binary files /dev/null and b/app/assets/images/icons/collection-items.png differ diff --git a/app/assets/images/icons/collection-remove.png b/app/assets/images/icons/collection-remove.png new file mode 100644 index 0000000000000000000000000000000000000000..863bb099f22a6c7c57bb6239727231ecb41b1f30 Binary files /dev/null and b/app/assets/images/icons/collection-remove.png differ diff --git a/app/assets/images/icons/collection.png b/app/assets/images/icons/collection.png new file mode 100644 index 0000000000000000000000000000000000000000..ba020f3199a45af971987ad77a5cfb83f8a81609 Binary files /dev/null and b/app/assets/images/icons/collection.png differ diff --git a/app/assets/images/icons/comments.png b/app/assets/images/icons/comments.png new file mode 100644 index 0000000000000000000000000000000000000000..d6e736420a7c5d71982c603cc471733e680135b0 Binary files /dev/null and b/app/assets/images/icons/comments.png differ diff --git a/app/assets/images/icons/contrast.png b/app/assets/images/icons/contrast.png new file mode 100644 index 0000000000000000000000000000000000000000..acb1f5b8447cf69fbf2645a3b1bb6f215d0ee684 Binary files /dev/null and b/app/assets/images/icons/contrast.png differ diff --git a/app/assets/images/icons/download.png b/app/assets/images/icons/download.png new file mode 100644 index 0000000000000000000000000000000000000000..af9243b430f11515a84a224bcae47b93ef11f1e0 Binary files /dev/null and b/app/assets/images/icons/download.png differ diff --git a/app/assets/images/icons/filter.png b/app/assets/images/icons/filter.png new file mode 100644 index 0000000000000000000000000000000000000000..1bf31b8cebf7fdfdfd922676ce2a95c6e74bc408 Binary files /dev/null and b/app/assets/images/icons/filter.png differ diff --git a/app/assets/images/icons/font-minus.png b/app/assets/images/icons/font-minus.png new file mode 100644 index 0000000000000000000000000000000000000000..53c8d5c33d9671bc2e0ee4f3ac95de40b75307ac Binary files /dev/null and b/app/assets/images/icons/font-minus.png differ diff --git a/app/assets/images/icons/font-plus.png b/app/assets/images/icons/font-plus.png new file mode 100644 index 0000000000000000000000000000000000000000..e0d32fd6f4a2a6d60bdbaa0c4c4e8641d23eff71 Binary files /dev/null and b/app/assets/images/icons/font-plus.png differ diff --git a/app/assets/images/icons/report-circle.png b/app/assets/images/icons/report-circle.png new file mode 100644 index 0000000000000000000000000000000000000000..d5d078817dca175f6f9a01ec9271ca44da5c1f6c Binary files /dev/null and b/app/assets/images/icons/report-circle.png differ diff --git a/app/assets/images/icons/report.png b/app/assets/images/icons/report.png new file mode 100644 index 0000000000000000000000000000000000000000..a26bb4aab44e9806465f0f69dfc60c18e661b66f Binary files /dev/null and b/app/assets/images/icons/report.png differ diff --git a/app/assets/images/icons/search.png b/app/assets/images/icons/search.png new file mode 100644 index 0000000000000000000000000000000000000000..3faefcad4dded07baee7fe6a7da06cc0842f137c Binary files /dev/null and b/app/assets/images/icons/search.png differ diff --git a/app/assets/images/icons/selection-copy.png b/app/assets/images/icons/selection-copy.png new file mode 100644 index 0000000000000000000000000000000000000000..1dabd051939bc6c97786f3e2246aebf7cdefcd81 Binary files /dev/null and b/app/assets/images/icons/selection-copy.png differ diff --git a/app/assets/images/icons/selection-download.png b/app/assets/images/icons/selection-download.png new file mode 100644 index 0000000000000000000000000000000000000000..46168302edc3557bdcdccd1aea08111881defe07 Binary files /dev/null and b/app/assets/images/icons/selection-download.png differ diff --git a/app/assets/images/icons/selection-move.png b/app/assets/images/icons/selection-move.png new file mode 100644 index 0000000000000000000000000000000000000000..f242b1b3397e00100c0f9db08fb442b28b2d710b Binary files /dev/null and b/app/assets/images/icons/selection-move.png differ diff --git a/app/assets/images/icons/star-gold.png b/app/assets/images/icons/star-gold.png new file mode 100644 index 0000000000000000000000000000000000000000..14d216f875885a2b3ab8f92ff7129b139da0363e Binary files /dev/null and b/app/assets/images/icons/star-gold.png differ diff --git a/app/assets/images/icons/star-grey.png b/app/assets/images/icons/star-grey.png new file mode 100644 index 0000000000000000000000000000000000000000..d56e678777363b947eee5f8a534a6a5bce87ee13 Binary files /dev/null and b/app/assets/images/icons/star-grey.png differ diff --git a/app/assets/images/icons/upload-add.png b/app/assets/images/icons/upload-add.png new file mode 100644 index 0000000000000000000000000000000000000000..5e458c3752b65e7a12d98904ee033fc193a604ab Binary files /dev/null and b/app/assets/images/icons/upload-add.png differ diff --git a/app/assets/images/icons/upload.png b/app/assets/images/icons/upload.png new file mode 100644 index 0000000000000000000000000000000000000000..ed76e10e18e65b5f1521311c21331b6e3cfeec31 Binary files /dev/null and b/app/assets/images/icons/upload.png differ diff --git a/app/assets/images/icons/visualization.png b/app/assets/images/icons/visualization.png new file mode 100644 index 0000000000000000000000000000000000000000..12a1183a472acb3b7e77d2afb241ab54b7fc8288 Binary files /dev/null and b/app/assets/images/icons/visualization.png differ diff --git a/app/assets/images/learning-object-preview.png b/app/assets/images/learning-object-preview.png new file mode 100644 index 0000000000000000000000000000000000000000..4b52e2eb2c0448bbbc602e0d4d7e42ba7909bd94 Binary files /dev/null and b/app/assets/images/learning-object-preview.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4a67b4eb08cd76ebb73800a90723ca44edd74fcc..608172a8ce87f463e76c3ad98f01d9fb013897e7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,4 +16,4 @@ //= require jquery.turbolinks //= require bootstrap-sprockets //= require select2 -//= require_tree ./application +//= require_tree ./application \ No newline at end of file diff --git a/app/assets/javascripts/application/accessibility.js b/app/assets/javascripts/application/accessibility.js index 7e240dc34bbaee04b3fa5bc7d973370b38682fd9..ccf9bf19d494131a5fbf278a52ccb2e963e9c965 100644 --- a/app/assets/javascripts/application/accessibility.js +++ b/app/assets/javascripts/application/accessibility.js @@ -18,6 +18,9 @@ var fontSize = function() { reloadFontSize(size_c); }); } + else { + createCookie('fontSize', 0, 365); + } function reloadFontSize(size) { var i = 0; diff --git a/app/assets/javascripts/application/columns.js b/app/assets/javascripts/application/columns.js new file mode 100644 index 0000000000000000000000000000000000000000..9a24c897df0bacefd95b1242da0fa49b05f05403 --- /dev/null +++ b/app/assets/javascripts/application/columns.js @@ -0,0 +1,24 @@ +$(document).ready(function() { + $(".learning-object-columns").each(function() { + var html = '', + i = 1; + + $("> div", this).each(function () { + if (i == 2) { + html = '<div class="col-md-6"><div class="row"><div class="col-md-3"> </div><div class="col-md-6">'; + // TODO: find a way to not remove wrapper div + html += $(this).clone().wrap('<div>').parent().html(); + html += '</div><div class="col-md-3"> </div></div></div>'; + $(this).replaceWith(html); + + i = 0; + } + else { + $(this).wrap('<div class="col-md-3"></div>'); + + i += 1; + } + }); + }); + +}); diff --git a/app/assets/javascripts/application/learning_objects.coffee b/app/assets/javascripts/application/learning_objects.coffee new file mode 100644 index 0000000000000000000000000000000000000000..73baa059e446ec8673cd24fb1e70d3395e8ba919 --- /dev/null +++ b/app/assets/javascripts/application/learning_objects.coffee @@ -0,0 +1,6 @@ +$ -> + $('.add_to_collection').popover + html: true + content: -> + $('#collections_list_popover').html() + return \ No newline at end of file diff --git a/app/assets/javascripts/application/search.js b/app/assets/javascripts/application/search.js new file mode 100644 index 0000000000000000000000000000000000000000..ed6954101b77e8467e0340a47d99004749a9acd4 --- /dev/null +++ b/app/assets/javascripts/application/search.js @@ -0,0 +1,20 @@ +$(document).ready(function () { + $(".select-tag-container").select2(); + + var runDropdown = function (element) { + if ($(element).next().is(':hidden')) { + $('> .caret', element).addClass('caret-up'); + $(element).next().slideDown(); + } + else { + $('> .caret', element).removeClass('caret-up'); + $(element).next().slideUp(); + } + }; + + runDropdown($('.nestedAccordion .dropdown')); + + $('.nestedAccordion .dropdown').click(function () { + runDropdown(this); + }); +}); diff --git a/app/assets/javascripts/learning_objects.coffee b/app/assets/javascripts/management/carousel.coffee similarity index 100% rename from app/assets/javascripts/learning_objects.coffee rename to app/assets/javascripts/management/carousel.coffee diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 07be7e357095acaf18a37beea0bd3e303c2b8972..0d80b3a998fd3240c7e56fa9541cdf5d5901893c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -19,6 +19,7 @@ @import "select2-bootstrap"; $header-blue: #1676bc; +$link-grey: #343D3E; //// HTML/BODY html, @@ -28,13 +29,24 @@ body { height:100%; font-size: 100%; + font-weight: 300; font-family: 'Roboto', "Helvetica Neue", Helvetica, Arial, sans-serif; } +h1, h2, h3, h4, h5, h6 { + margin: 0; + font-weight: 300; +} + a, a:focus, a:hover { + font-weight: 400; color: #000; } +.media-heading { + font-weight: 400; +} + .caret { border-left: 7px solid transparent; border-right: 7px solid transparent; @@ -52,9 +64,6 @@ a, a:focus, a:hover { //// HEADER header { border: 0; - border-bottom: 1px; - border-style: solid; - border-color: $header-blue; margin-bottom: 16px; a, a:focus, a:hover { @@ -91,14 +100,13 @@ header { } .logo { margin-top: 10px; - padding: 0px; - // font-size: 24px; - font-weight: bold; + padding: 0; text-align: center; float: left; width: 165px; h3 { margin-top: 10px; + font-weight: 400; } a { color: #FFF; @@ -195,9 +203,14 @@ header { padding-left: 15px; padding-right: 10px; // font-size: 20px; + color: #343D3E; font-weight: 500 !important; - a { color: #000; } + a { + @extend h3; + padding: 0; + color: #343D3E; + } } .nav-button-first { @@ -244,11 +257,6 @@ footer { } } -//// partial OBJECT -.learning-object-horizontal, .learning-object-vertical { - margin-bottom: 20px; -} - .starRating:not(old){ display : inline-block; width : 7.5em; diff --git a/app/assets/stylesheets/application/learning_objects.scss b/app/assets/stylesheets/application/learning_objects.scss index a3271c7b29c97008138c4b5a0535a114e4395c57..a6fb67e1a6ecd30625322f9ab5d4ebd8c8154214 100644 --- a/app/assets/stylesheets/application/learning_objects.scss +++ b/app/assets/stylesheets/application/learning_objects.scss @@ -1,3 +1,98 @@ -.learning_object-horizontal { - margin-bottom: 10px; -} \ No newline at end of file +$background-grey: #e7e7e8; + +.learning-object-horizontal, .learning-object-vertical { + margin-bottom: 20px; + + .panel-body { + padding: 0 !important; + margin-top: 3px; + } + + .media-heading { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + .learning-object-thumbnail { + min-width: 250px; + height: 141px; + position: relative; + + .learning-object-actions { + position: absolute; + bottom: 5px; + right: 5px; + } + } +} + +.learning-object-vertical { + + .learning-object-thumbnail { + max-width: 250px; + height: 150px; + position: relative; + } + +} + +.glyphicon-eye-open:before, .glyphicon-star:before { + margin-right: 5px; +} + +.learning-object { + .thumbnail { + width: 530px; + height: 298px; + } + .stats { + text-align: right; + } + .title { + font-weight: 400; + } + .description { + padding-left: 3%; + padding-top: 10px; + } + .category { + font-weight: 400; + } + .rightbar { + margin-top: 230px; + + .media-heading { + white-space: nowrap; + } + .rating-panel { + background-color: $background-grey; + width: 100%; + height: 100px; + padding: 10px; + padding-left: 20px; + padding-right: 20px; + + .rating { + text-align: right; + } + } + + .actions { + text-align: center; + color: #F05421; + font-weight: 400; + + .action { + margin-top: 10px; + padding: 0; + + img { + width: 40px; + height: 40px; + margin-bottom: 5px; + } + } + } + } +} diff --git a/app/assets/stylesheets/application/search.scss b/app/assets/stylesheets/application/search.scss index 1e0bc46ea2011f1067d4676045b61a33b8fb2652..71452e6b0119474729e8e70a4b150a3aeea38d6d 100644 --- a/app/assets/stylesheets/application/search.scss +++ b/app/assets/stylesheets/application/search.scss @@ -7,6 +7,13 @@ } } +.nestedAccordion { + .dropdown { + margin-top: 10px !important; + margin-bottom: 10px !important; + } +} + .select2-container { width: 100% !important; } diff --git a/app/assets/stylesheets/application/users.scss b/app/assets/stylesheets/application/users.scss index 334ce327e22cfb358fe6cdb6a6b8a2306f84ae9a..4cd7e33dd95478ddea6b9b9caa6c471cae7c5d5a 100644 --- a/app/assets/stylesheets/application/users.scss +++ b/app/assets/stylesheets/application/users.scss @@ -1,17 +1,42 @@ $header-blue: #1676bc; +$link-grey: #343D3E; +$background-grey: #e7e7e8; .user-image { width: 60px; height: 60px; border-radius: 50%; } +.user-image-small { + width: 40px; + height: 40px; + border-radius: 50%; +} +.user-image-tiny { + width: 20px; + height: 20px; + border-radius: 50%; +} .user-header { - background-color: #e7e7e8; + background-color: $background-grey; width: 100%; - min-height: 100px; + height: 145px; + margin-top: 30px; + margin-bottom: 50px; padding: 15px; + h2 { + font-weight: 400; + } + .header-sub { + margin-top: 0; + color: $link-grey; + font-style: italic; + } + .header-content { + } + .right-column { text-align: right; @@ -23,3 +48,7 @@ $header-blue: #1676bc; } } } + +.user-files { + +} diff --git a/app/assets/stylesheets/application/welcome.scss b/app/assets/stylesheets/application/welcome.scss index 293aecd53359ddd05db69e7f4d3dd9978247120a..57c821daaf2a5ba7402e7a832c67c36bb5fecb4d 100644 --- a/app/assets/stylesheets/application/welcome.scss +++ b/app/assets/stylesheets/application/welcome.scss @@ -15,7 +15,6 @@ $carousel_size: 400px; .carousel { height: $carousel_size; - margin-bottom: 60px; h1{ background-color: rgba(37, 68, 32, 0.75); } @@ -27,6 +26,9 @@ $carousel_size: 400px; .carousel h1 { background-color: rgba(0, 0, 0, 0.75); } +.carousel ol { + background-color: rgba(0, 0, 0, 0.10); +} .carousel-caption { z-index: 10; @@ -41,7 +43,8 @@ $carousel_size: 400px; top: 0; left: 0; min-width: 100%; - height: $carousel_size; + height: 400px !important; + } .carousel-indicators li { diff --git a/app/assets/stylesheets/management/carousel.scss b/app/assets/stylesheets/management/carousel.scss new file mode 100644 index 0000000000000000000000000000000000000000..89da7e1046eebfd411c84d8414cc3ac48ec4ea90 --- /dev/null +++ b/app/assets/stylesheets/management/carousel.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the management/carousel controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 374155aaae133f416c4eb513e34151f23766d8bd..99459ecff26a0f9df6456eeebbcee08eb1dd7dd3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,13 +1,11 @@ class ApplicationController < ActionController::Base + include RepositoriesProxy + # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session before_action :configure_permitted_parameters, if: :devise_controller? - def repository - Portalmec::Application.repository - end - protected def configure_permitted_parameters diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 6edf2387280c0305d5a85cd77af40cb30647e494..877924667c44c85880435b2737eb59399b4fbcb9 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -59,10 +59,6 @@ class CollectionsController < ApplicationController @collection = collection_repository.find params[:id] end - def collection_repository - repository.for(:collection) - end - # Never trust parameters from the scary internet, only allow the white list through. def collection_params params.require(:collection).permit(:name, :privacy, learning_objects: []) diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb index 96c21aa17d468af0acb632a45c2cbc9eb9de3bfc..b668a26a983e732e35f363de431f1c24eda430b4 100644 --- a/app/controllers/institutions_controller.rb +++ b/app/controllers/institutions_controller.rb @@ -57,18 +57,12 @@ class InstitutionsController < ApplicationController 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] diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index 3ded253c23cd10465b3624db636413ac3bf7b848..a1e384b0a65f098238a181b9098d1f9fc85fcc84 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -67,10 +67,6 @@ class LearningObjectsController < ApplicationController private - def learning_object_repository - repository.for(:learning_object) - end - # Use callbacks to share common setup or constraints between actions. def set_learning_object @learning_object = learning_object_repository.find params[:id] diff --git a/app/controllers/management/carousels_controller.rb b/app/controllers/management/carousels_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..b39f2c5bb0e2d4a120d6c6111dba53d9ff836c4b --- /dev/null +++ b/app/controllers/management/carousels_controller.rb @@ -0,0 +1,55 @@ +class Management::CarouselsController < ManagementController + before_action :set_carousel, only: [:edit, :update, :destroy] + + def index + @carousels = carousel_repository.all + end + + def new + @carousel = Carousel.new + end + + def create + @carousel = Carousel.new(carousel_params) + + respond_to do |format| + if carousel_repository.save @carousel + format.html { redirect_to management_carousels_path } + else + format.html { render :new } + end + end + end + + def edit + end + + def update + respond_to do |format| + if carousel_repository.update(@carousel, carousel_params) + format.html { redirect_to management_carousels_path } + else + format.html { render :edit } + end + end + end + + def destroy + @carousel.image = nil + carousel_repository.destroy @carousel + respond_to do |format| + format.html { redirect_to management_carousels_path } + end + end + + private + + def set_carousel + @carousel = carousel_repository.find params[:id] + end + + def carousel_params + params.require(:carousel).permit(:title, :url, :image) + end + +end diff --git a/app/controllers/management/highlights_controller.rb b/app/controllers/management/highlights_controller.rb deleted file mode 100644 index 2c91db6b179c71322b42d85ffff779913da35d78..0000000000000000000000000000000000000000 --- a/app/controllers/management/highlights_controller.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Management::HighlightsController < ManagementController - - def index - @highlights = highlight_repository.find_all - end - - def show - end - - def new - end - - def delete - @highlights = highlight_repository.find_all - end - - def create - - highlight_repository.insert_data(params[:name],params[:url]) - redirect_to management_highlights_index_path - - end - - def destroy - - params[:id].each do |id| - highlight_repository.destroy_data(id) - end - redirect_to management_highlights_index_path - - end - - private - - def highlight_repository - repository.for :highlight - end - - -end diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index 4c6de9d93bc5e37daaf181fa63076625b43d02ae..610ab321929077af82d6e00563a06ed98e6f6d50 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -26,7 +26,7 @@ class Management::UsersController < ManagementController @user = User.new(user_params) respond_to do |format| - if @user.save + if user_repository.save @user format.html { redirect_to management_user_path(@user), notice: "User created!" } format.json { render :show, status: :created, location: @user } else @@ -69,10 +69,6 @@ class Management::UsersController < ManagementController params.require(:user).permit(:name, :email, :password, :password_confirmation, roles: []) end - def user_repository - repository.for(:user) - end - def set_roles @roles = Role.all end diff --git a/app/controllers/management_controller.rb b/app/controllers/management_controller.rb index 6db75c2c7f0cc891b5a3da1010a0ae330923a3de..ef890daa346304084f5f8b2fea71edf2ad7aa555 100644 --- a/app/controllers/management_controller.rb +++ b/app/controllers/management_controller.rb @@ -1,3 +1,5 @@ class ManagementController < ApplicationController + before_action :authenticate_user! + layout 'management' end diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..7d900a69851a286d944a48c8c39abae5c5b3f1db --- /dev/null +++ b/app/controllers/subjects_controller.rb @@ -0,0 +1,22 @@ +class SubjectsController < ApplicationController + + # GET /subjects + # GET /subjects.json + def index + @subjects = subject_repository.all + end + + # GET /subjects/1 + # GET /subjects/1.json + def show + @subject = subject_repository.find("##{params[:id]}") + end + + private + + # Never trust parameters from the scary internet, only allow the white list through. + def subject_params + params[:subject_object] + end + +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 16a142622ac082465d1222429fbd9bfb45ff0dcd..cda7f8ed990b71a14c0076ffaa4560a8e631ccc0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,7 @@ class UsersController < ApplicationController + def show - @objects = repository.for(:learning_object).all + @objects = learning_object_repository.all end + end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index c3353d960229b8a8882d717ab44145b7996c6ea7..fe3ed8bfe169d3978c056b92761cc29e7478fbf7 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -3,27 +3,17 @@ class WelcomeController < ApplicationController def index @Carousel = Array.new @General = Array.new - mainPage = repository.for(:mainPage).find_all.first + mainPage = main_page_repository.all.first - @Carousel = mainPage["carousel"].collect do |id| - repository.for(:webLink).find_by_id(id)[0] #orientdb returns a hash inside an array, I want only the hash - end + @Carousel = carousel_repository.all @General = mainPage["highlights"].collect do |id| - repository.for(:learning_object).find(id) - end - - @Subjects = repository.for(:subject).find_all.take(8) - @Subjects.delete_if do |subject| - if subject['highlights'].nil? || subject['highlights'].empty? - true - end - end - @Subjects.each do |subject| - object = repository.for(:learning_object).find(subject['highlights'].first) - subject['first_highlight'] = object + learning_object_repository.find(id) end + @Subjects = subject_repository.all + @Subjects.delete_if{|s| not s.highlights.present?} + @Subjects = @Subjects.take(8) end def faq @@ -31,4 +21,5 @@ class WelcomeController < ApplicationController def contact end + end diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..4dfbadf4fbe3f941a742f21b7854f8b76e3970a8 --- /dev/null +++ b/app/helpers/collections_helper.rb @@ -0,0 +1,9 @@ +module CollectionsHelper + + ## + # x objetos educacionais + def collection_length(collection) + "#{collection.learning_objects.count} objetos educacionais nessa coleção" + end + +end \ No newline at end of file diff --git a/app/helpers/learning_objects_helper.rb b/app/helpers/learning_objects_helper.rb index 0860a208641c0d3ba8ee4ba980905f5b29d1e04a..eea95b9a4caf2e8ee370140c660411b841d9cf4b 100644 --- a/app/helpers/learning_objects_helper.rb +++ b/app/helpers/learning_objects_helper.rb @@ -4,6 +4,22 @@ module LearningObjectsHelper categories.to_s end + def learning_object_thumbnail(learning_object) + if learning_object.thumbnail == "thumbnai" + image_tag('learning-object-preview.png') + else + image_tag learning_object.thumbnail, alt: learning_object_title(learning_object) + end + end + + def learning_object_title(learning_object) + if learning_object.name.nil? + return 'Sem TÃtulo' + end + + learning_object.name + end + def render_learning_object(orientation, learning_object) case (orientation) when "vertical" @@ -15,4 +31,8 @@ module LearningObjectsHelper end end + def collections_list(learning_object) + collections = @collections.diff(learning_object_collections(learning_object)) + end + end diff --git a/app/helpers/management/carousel_helper.rb b/app/helpers/management/carousel_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..d764ece79ca86f013cdc68b230deefd2789f3c99 --- /dev/null +++ b/app/helpers/management/carousel_helper.rb @@ -0,0 +1,2 @@ +module Management::CarouselHelper +end diff --git a/app/models/attribute.rb b/app/models/attribute.rb new file mode 100644 index 0000000000000000000000000000000000000000..af0710be3bf389b3fec994e82629afaccbc4e199 --- /dev/null +++ b/app/models/attribute.rb @@ -0,0 +1,6 @@ +class Attribute + include ActiveModel::Model + + attr_accessor :id, :key, :value + +end \ No newline at end of file diff --git a/app/models/carousel.rb b/app/models/carousel.rb new file mode 100644 index 0000000000000000000000000000000000000000..e8a81d995ee3d9d870b2e3915ac5032f5cc35ab6 --- /dev/null +++ b/app/models/carousel.rb @@ -0,0 +1,7 @@ +class Carousel < ActiveRecord::Base + has_attached_file :image, styles: { + larger: "600x600>", + thumbnail: "100x100>" + }, default_url: "/images/:style/missing.png" + validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/ +end diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index 3290fc7c5f3a8a842f5e5fd695f2cee638d4b325..b28f497a28be4e68517e93f9ae4d0448bbcbbdd8 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -2,7 +2,8 @@ class LearningObject include ActiveModel::Model attr_accessor :id, :id_dspace, :rid, :name, :description, :thumbnail, :created_at, :last_modified, - :type, :bitstreams, :metadata, :likes, :views, :downloads + :type, :bitstreams, :metadata, :likes, :views, + :downloads, :subjects, :attributes validates_presence_of :name, :created_at, :type, :likes, :views, :downloads validates_numericality_of :likes, greater_than_or_equal_to: 0 @@ -17,14 +18,37 @@ class LearningObject @subjects ||= learning_object_repository.get_subjects(self) end + def attributes + @attributes ||= learning_object_repository.get_attributes(self) + end + def categories get_metadata_value_of 'dc.subject.category' end def get_metadata_value_of key - values = @metadata.select { |v| v["key"] == key } + get_metadata_values_of(key).first + end + + def get_metadata_values_of key + values = [] + @metadata.each do |m| + values << m["value"] if m["key"] == key + end + values + end + + def get_bitstream_retrievelink_of name + values = @bitstreams.select { |v| v["bundleName"] == name } + unless values.empty? + return Dspace::Config.rest_url + values.first["retrieveLink"] + end + end + + def get_bitstream_filename_of name + values = @bitstreams.select { |v| v["bundleName"] == name } unless values.empty? - return values.first["value"] + return values.first["name"] end end @@ -35,7 +59,7 @@ class LearningObject likes: 0, views: 0, downloads: 0, - date_creation: DateTime.new + created_at: DateTime.new } end @@ -43,4 +67,4 @@ class LearningObject Portalmec::Application.repository.for :learning_object end -end \ No newline at end of file +end diff --git a/app/models/subject.rb b/app/models/subject.rb index 58e25fa4d60b98f24147ccee7839f0dee1e01bc7..4aa1d1c169fd5cc3836a341159864376e60bd7e6 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -1,5 +1,12 @@ class Subject include ActiveModel::Model + attr_accessor :id, :created_at, :description, :highlights, :name - attr_accessor :id, :dateCreation, :description, :highlights, :name + def highlights + @highlights ||= subject_repository.get_highlights(self) + end + + def subject_repository + Portalmec::Application.repository.for :subject + end end \ No newline at end of file diff --git a/app/models/web_link.rb b/app/models/web_link.rb deleted file mode 100644 index ee1edc1eb3bb5c4369e1448629534530a3af286b..0000000000000000000000000000000000000000 --- a/app/models/web_link.rb +++ /dev/null @@ -1,4 +0,0 @@ -class WebLink - include ActiveModel::Model - attr_accessor :id, :dateCreation, :description, :name, :thumbnail, :url -end \ No newline at end of file diff --git a/app/repositories/active_record/carousel_repository.rb b/app/repositories/active_record/carousel_repository.rb index bfec616aa00ec56993f360f1f7cc03b22d12133c..cb77877a8cde65fb8e7aacbefae0ef33a29e0a27 100644 --- a/app/repositories/active_record/carousel_repository.rb +++ b/app/repositories/active_record/carousel_repository.rb @@ -1,14 +1,22 @@ -module ActiveRecord - class CarouselRepository +## +# This carousel repository delegates all behavior to ActiveRecord +class ActiveRecord::CarouselRepository - def find_all - end + def save(carousel) + carousel.save + end - def find_by_id - end + def save!(carousel) + carousel.save! + end - def insert_data(name, url) - end + def method_missing(method_name, *arguments, &block) + Carousel.send(method_name, *arguments, &block) + end + + def respond_to?(method_name, include_private = false) + Carousel.respond_to?(method_name) || super end + end diff --git a/app/repositories/active_record/learning_object_repository.rb b/app/repositories/active_record/learning_object_repository.rb deleted file mode 100644 index 66a3d4ea20afc0bacc80dbe47589defee4f0b22d..0000000000000000000000000000000000000000 --- a/app/repositories/active_record/learning_object_repository.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveRecord - class LearningObjectRepository - - def find_all - end - - def find_by_id - end - - def insert_data(name, url) - end - - end -end diff --git a/app/repositories/active_record/main_page_repository.rb b/app/repositories/active_record/main_page_repository.rb deleted file mode 100644 index 656aab684c7eaa33e845387038aee21882f2615f..0000000000000000000000000000000000000000 --- a/app/repositories/active_record/main_page_repository.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveRecord - class MainPageRepository - - def find_all - end - - def find_by_id - end - - def insert_data(name, url) - end - - end -end diff --git a/app/repositories/active_record/subject_repository.rb b/app/repositories/active_record/subject_repository.rb deleted file mode 100644 index dcccbb258a48790ca63d82e9de706190b23480f3..0000000000000000000000000000000000000000 --- a/app/repositories/active_record/subject_repository.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveRecord - class SubjectRepository - - def find_all - end - - def find_by_id - end - - def insert_data(name, url) - end - - end -end diff --git a/app/repositories/active_record/weblink_repository.rb b/app/repositories/active_record/weblink_repository.rb deleted file mode 100644 index a717c04fd8f450ca3d0e531ee82075d8614bde0e..0000000000000000000000000000000000000000 --- a/app/repositories/active_record/weblink_repository.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveRecord - class WeblinkRepository - - def find_all - end - - def find_by_id - end - - def insert_data(name, url) - end - - end -end diff --git a/app/repositories/orient_db/attribute_repository.rb b/app/repositories/orient_db/attribute_repository.rb new file mode 100644 index 0000000000000000000000000000000000000000..4c5373180e4f1aac39f80384dd3c8f78288ff5ba --- /dev/null +++ b/app/repositories/orient_db/attribute_repository.rb @@ -0,0 +1,30 @@ +module OrientDb + class AttributeRepository < Base + + def find_by_key_and_value(key, value) + result = connection.query sprintf("SELECT FROM %s WHERE key = '%s' AND value = '%s'", odb_class, key, value) + build_objects(result) + end + + def build_object(args={}) + subject = nil + unless args.nil? + subject = Attribute.new(:id => args["@rid"]) + args.each do |var, val| + var_name = "@"+var + if subject.respond_to?(var) + subject.instance_variable_set(var_name, val) + end + end + end + subject + end + + private + + def odb_class + "Attribute" + end + + end +end \ No newline at end of file diff --git a/app/repositories/orient_db/base.rb b/app/repositories/orient_db/base.rb index 53599f9125b196ed8d4d04a645719a3419ad04c8..6544e22fb661e89692fcc9e04a6999401301854a 100644 --- a/app/repositories/orient_db/base.rb +++ b/app/repositories/orient_db/base.rb @@ -1,12 +1,66 @@ class OrientDb::Base + include OrientDb::Methods::GenericMethods def initialize(orientdb_connection) @connection = orientdb_connection end - def connection @connection end + def find(id) + result = get_by_rid(id) + build_object result + end + + def all + objects_hash = connection.query "SELECT FROM #{odb_class}", :limit => -1 + objects = build_objects(objects_hash) || [] + end + + def all_from_offset_to_limit(offset, limit) + objects_hash = connection.query "SELECT FROM #{odb_class} SKIP #{offset}", :limit => limit + objects = build_objects(objects_hash) || [] + end + + def destroy(object) + connection.command sprintf("DELETE VERTEX %s", object.id) + end + + def create(object) + hash = build_hash(object) + result = connection.create_document(hash) + object.id = result["@rid"] + object + end + + def build_objects(hash=[]) + objects = [] + hash.each do |h| + objects << build_object(h) + end + objects + end + + def build_hash(object) + hash = {} + hash["@class"] = odb_class + object.instance_variables.each do |var| + var_name = var.to_s.gsub(/\A@/, "") + hash[var_name] = object.instance_variable_get(var) + end + hash + end + + def build_object(args={}) + raise NoMethodError, "You must implement this method" + end + + private + + def odb_class + raise NoMethodError, "You must implement this method" + end + end diff --git a/app/repositories/orient_db/carousel_repository.rb b/app/repositories/orient_db/carousel_repository.rb deleted file mode 100644 index a8a2d8c0a0c529dba2d7a43e4d02a0adfe9f5dd5..0000000000000000000000000000000000000000 --- a/app/repositories/orient_db/carousel_repository.rb +++ /dev/null @@ -1,24 +0,0 @@ -module OrientDb - class CarouselRepository < Base - - def find_all - connection.query "SELECT FROM Carousel" - end - - def find_by_id(id) - connection.query "SELECT FROM Carousel where @rid = '#{id}'" - end - - def insert_data (name,url) - connection.command "INSERT INTO Carousel (name,URL) VALUES ('#{name}','#{url}')" - end - - - def destroy_data(id) - return @connection.command "DELETE VERTEX Carousel where @rid = '#{id}'" - rescue - return nil - end - - end -end diff --git a/app/repositories/orient_db/collection_repository.rb b/app/repositories/orient_db/collection_repository.rb index a597b2ca3db07e288434284982510cccedbef7a6..56f36ebd8e7606f904184479006efa659ec313ae 100644 --- a/app/repositories/orient_db/collection_repository.rb +++ b/app/repositories/orient_db/collection_repository.rb @@ -2,41 +2,17 @@ module OrientDb class CollectionRepository < Base include OrientDb::Methods::EdgeMethods - def all - hash = connection.query "SELECT FROM Collection" - collections = build_collections(hash) - end - - # Usage: - # collection = repository.for(:collections).find '#14:14' - def find(id) - result = connection.query "SELECT FROM #{id}" - build_collection result.first - end - - # Usage: - # repository.for(:collections).destroy collection - # - def destroy(collection) - connection.command sprintf("DELETE VERTEX %s", collection.id) - end - - private - - def build_collection(args={}) + def build_object(args={}) Collection.new( :id => args["@rid"], :name => args["name"] ) end - def build_collections(hash=[]) - collections = [] - hash.each do |h| - collections << build_collection(h) - end + private - collections + def odb_class + "Collection" end end diff --git a/app/repositories/orient_db/highlight_repository.rb b/app/repositories/orient_db/highlight_repository.rb deleted file mode 100644 index 046f724c400c0c75f1314c937999432d4cbb6936..0000000000000000000000000000000000000000 --- a/app/repositories/orient_db/highlight_repository.rb +++ /dev/null @@ -1,18 +0,0 @@ -module OrientDb - class HighlightRepository < Base - - def find_all - connection.query "Select highlights FROM MainPage" - end - - def insert_data (name, url) - connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')" - end - - - def destroy_data(id) - @connection.command "DELETE VERTEX Highlight where @rid = '#{id}'" - end - - end -end diff --git a/app/repositories/orient_db/institution_repository.rb b/app/repositories/orient_db/institution_repository.rb index 6bc0e470f058a2ff7d0dce33ec002053c7472200..028e13b96f04e1747c3e2825ad6e2638be70bb41 100644 --- a/app/repositories/orient_db/institution_repository.rb +++ b/app/repositories/orient_db/institution_repository.rb @@ -2,24 +2,6 @@ module OrientDb class InstitutionRepository < Base include OrientDb::Methods::EdgeMethods - # Example: - # list = repository.for(:institutions).all - # list.each do |institution| - # institution_object.inspect <LearningObject model> - # end - def all - hash = connection.query "SELECT FROM Institution" - institutions = build_institutions(hash) - end - - # Usage: - # institution = repository.for(:institutions).get_by_dspace_id 123 - # - def find(id) - result = connection.query "SELECT FROM #{id}" - build_institution result.first - end - def create(name, url) connection.command sprintf("INSERT INTO Institution (name) VALUES ('%s')", name) end @@ -31,21 +13,17 @@ module OrientDb connection.command sprintf("DELETE VERTEX %s", institution.id) end - private - - def build_institution(args={}) + def build_object(args={}) return Institution.new( :id => args["@rid"], :title => args["title"], ) end - def build_institutions(hash=[]) - institutions = [] - hash.each do |h| - institutions << build_institution(h) - end - return institutions + private + + def odb_class + "Institution" end end diff --git a/app/repositories/orient_db/learning_object_repository.rb b/app/repositories/orient_db/learning_object_repository.rb index b15496835163b9045c69a23ef74d9d8c324583f1..2a3d779a4cc5ef2b34cc4118e50f58e9df5fdae0 100644 --- a/app/repositories/orient_db/learning_object_repository.rb +++ b/app/repositories/orient_db/learning_object_repository.rb @@ -1,6 +1,7 @@ module OrientDb class LearningObjectRepository < Base include OrientDb::Methods::EdgeMethods + include RepositoriesProxy def increment_views(user, learning_object) create_edge "Views", user.rid, learning_object.id @@ -8,47 +9,44 @@ module OrientDb # # Usage: - # repository.for(:learning_objects).like @learning_object, current_user + # repository.for(:learning_objects).like current_user, @learning_object # def like(user, learning_object) create_edge "Likes", user.rid, learning_object.id end - # Example: - # list = repository.for(:learning_objects).all - # list.each do |learning_object| - # learning_object.inspect <LearningObject model> - # end - def all - learning_objects_hash = connection.query "SELECT FROM LearningObject" - build_learning_objects(learning_objects_hash) || [] - end - # Usage: # learning_object = repository.for(:learning_objects).get_by_dspace_id 123 # def get_by_dspace_id(id_dspace) - result = connection.query "SELECT FROM LearningObject WHERE id_dspace=#{id_dspace}" - build_learning_object result.first + result = select_by_property(odb_class, "id_dspace", id_dspace) + build_object result.first end - # Usage: - # learning_object = repository.for(:learning_objects).get_by_dspace_id 123 - # - def find(id) - result = connection.query "SELECT FROM #{id}" - build_learning_object result.first + def get_subjects(learning_object) + result = get_edges_end("IsAbout", "out", learning_object.id) + subject_repository.build_objects(result) end - def create(name, url) - connection.command sprintf("INSERT INTO LearningObject (name,URL) VALUES ('%s','%s')", name, url) + def get_attributes(learning_object) + result = get_edges_end("HasAttr", "out", learning_object.id) + attribute_repository.build_objects(result) end - # Usage: - # repository.for(:learning_objects).destroy learning_object - # - def destroy(learning_object) - connection.command sprintf("DELETE VERTEX LearningObject where @rid = '%s'", learning_object.id) + def create_relations(learning_object) + edges = create_edges_from_array("IsAbout", learning_object.id, learning_object.subjects, true) + edges << create_edges_from_array("HasAttr", learning_object.id, learning_object.attributes, true) + edges.flatten + end + + def save(learning_object) + result = connection.command "INSERT INTO LearningObject CONTENT #{learning_object.to_json}" + end + + def update_property(learning_object,property,value) + if accepted_properties.include? property + connection.command "UPDATE LearningObject SET #{property}='#{value}' WHERE @rid = #{learning_object.id}" + end end ## @@ -63,52 +61,64 @@ module OrientDb FROM index:learningobject_search WHERE key LUCENE '#{qry}' ", limit: -1 - learning_objects = build_learning_objects(learning_objects_hash) || [] + build_objects(learning_objects_hash) || [] end - private + def build_object(args={}) + lo = nil + unless args.nil? + lo = LearningObject.new(:id => args["@rid"], + :name => args["name"], + :description => args["description"], + :thumbnail => args["thumbnail"], + :created_at => args["created_at"], + :id_dspace => args["id_dspace"], + :type => args["type"], + :bitstreams => args["bitstreams"], + :metadata => args["metadata"], + :last_modified => args["last_modified"]) + lo.likes = args.has_key?("in_Likes") ? args["in_Likes"].size : 0 + lo.views = args.has_key?("in_Views") ? args["in_Views"].size : 0 + end + lo + end - def count_likes(learning_object) - get_in_edges_count "Likes", learning_object.id + def build_hash + hash = super + hash.delete("likes") + hash.delete("views") + hash.delete("downloads") + hash.delete("subjects") + hash.delete("attributes") + hash end - def count_views(learning_object) - get_in_edges_count "Views", learning_object.id + private + + def accepted_properties + ['thumbnail'] end - def build_learning_object(args={}) - lo = LearningObject.new(:id => args["@rid"], - :name => args["name"], - :description => args["description"], - :thumbnail => args["thumbnail"], - :date_creation => args["date_creation"], - :id_dspace => args["id_dspace"], - :type => args["type"], - :bitstreams => args["bitstreams"], - :metadata => args["metadata"], - :last_modified => args["last_modified"]) - - unless args["in_Likes"].nil? - lo.likes = args["in_Likes"].count - else - lo.likes = 0 + def create_edges_from_array(edge_class, id, array, unique=false) + edges = [] + array.each do |o| + unless unique && edge_exists?(edge_class, id, o.id) + edges << create_edge(edge_class, id, o.id) + end end + edges + end - unless args["in_Views"].nil? - lo.views = args["in_Views"].count - else - lo.views = 0 - end + def odb_class + "LearningObject" + end - lo + def count_likes(learning_object) + get_in_edges_count "Likes", learning_object.id end - def build_learning_objects(hash=[]) - learning_objects = [] - hash.each do |h| - learning_objects << build_learning_object(h) - end - learning_objects + def count_views(learning_object) + get_in_edges_count "Views", learning_object.id end end diff --git a/app/repositories/orient_db/main_page_repository.rb b/app/repositories/orient_db/main_page_repository.rb index 3b27e083e1bd9a4aa921ededa4827a67321d2a79..ab8e0b6cb28dae44779c4df32eab1ffc03ab45c1 100644 --- a/app/repositories/orient_db/main_page_repository.rb +++ b/app/repositories/orient_db/main_page_repository.rb @@ -1,11 +1,11 @@ module OrientDb class MainPageRepository < Base - def find_all + def all connection.query "SELECT FROM MainPage" end - def find_by_id(id) + def find(id) connection.query "SELECT FROM MainPage where @rid = '#{id}'" end @@ -20,9 +20,15 @@ module OrientDb return nil end - def update(id,operation,atributte,new) - puts "update #{id} #{operation} #{atributte} = #{new}" - connection.command "update #{id} #{operation} #{atributte} = #{new}" + #def update(id,operation,atributte,new) + # puts "update #{id} #{operation} #{atributte} = #{new}" + # connection.command "update #{id} #{operation} #{atributte} = #{new}" + #end + + private + + def odb_class + "MainPage" end end diff --git a/app/repositories/orient_db/subject_repository.rb b/app/repositories/orient_db/subject_repository.rb index b7889fc55699145ad441d9729a9e7ebde0d12b8b..6bc3f7147c2b06155971e59c8b457e43f7bdad45 100644 --- a/app/repositories/orient_db/subject_repository.rb +++ b/app/repositories/orient_db/subject_repository.rb @@ -1,27 +1,57 @@ module OrientDb class SubjectRepository < Base + include OrientDb::Methods::EdgeMethods + include RepositoriesProxy - def find_all - connection.query "SELECT FROM Subject", limit: -1 + def find_by_name(name) + result = select_by_property(odb_class, "name", name) + build_object(result.first) end - def find_by_id(id) - connection.query "SELECT FROM Subject where @rid = '#{id}'" + def destroy(id) + connection.command "DELETE VERTEX Subject where @rid = '#{id}'" end - def destroy_data(id) - return @connection.command "DELETE VERTEX Subject where @rid = '#{id}'" - rescue - return nil + #def update(id, operation, atributte, new_value) + # puts "update #{id} #{operation} #{atributte} = #{new_value}" + # connection.command "update #{id} #{operation} #{atributte} = #{new_value}" + #end + + def get_learning_objects(subject) + result = get_edges_end("IsAbout", "in", subject.id) + learning_object_repository.build_objects(result) + end + + def get_highlights(subject) + result = connection.query "SELECT expand(highlights) FROM #{subject.id}" + learning_object_repository.build_objects(result) end - def get_objects(id) - connection.query "select expand(in('IsAbout')) from #{id}" + def build_hash(object) + hash = super(object) + hash.delete("learning_objects") + hash end - def update(id,operation,atributte,new) - puts "update #{id} #{operation} #{atributte} = #{new}" - return @connection.command "update #{id} #{operation} #{atributte} = #{new}" + def build_object(args={}) + subject = nil + unless args.nil? + subject = Subject.new(:id => args["@rid"]) + args.each do |var, val| + var_name = "@"+var + if subject.respond_to?(var) && var != 'highlights' + subject.instance_variable_set(var_name, val) + end + end + end + subject end + + private + + def odb_class + "Subject" + end + end end diff --git a/app/repositories/orient_db/user_repository.rb b/app/repositories/orient_db/user_repository.rb index 28d930e8fe63de55ae83da66a0adc94188e25555..8068a3f257520146b9ee68607ad1773452c4dca3 100644 --- a/app/repositories/orient_db/user_repository.rb +++ b/app/repositories/orient_db/user_repository.rb @@ -24,5 +24,11 @@ module OrientDb (result.count > 0) end + private + + def odb_class + "User" + end + end end diff --git a/app/repositories/orient_db/weblink_repository.rb b/app/repositories/orient_db/weblink_repository.rb deleted file mode 100644 index 4141dc96de6761ccfe87e0d0e7da4d40c3691ff7..0000000000000000000000000000000000000000 --- a/app/repositories/orient_db/weblink_repository.rb +++ /dev/null @@ -1,24 +0,0 @@ -module OrientDb - class WeblinkRepository < Base - - def find_all - connection.query "SELECT FROM WebLink" - end - - def find_by_id(id) - connection.query "SELECT FROM WebLink where @rid = '#{id}'" - end - - def insert_data (name,url) - connection.command "INSERT INTO WebLink (name,URL) VALUES ('#{name}','#{url}')" - end - - - def destroy_data(id) - return @connection.command "DELETE VERTEX WebLink where @rid = '#{id}'" - rescue - return nil - end - - end -end diff --git a/app/repositories/repositories_proxy.rb b/app/repositories/repositories_proxy.rb new file mode 100644 index 0000000000000000000000000000000000000000..3fdfe2cbe2e1cc077a3a16fc271f99194a17d1bf --- /dev/null +++ b/app/repositories/repositories_proxy.rb @@ -0,0 +1,43 @@ +# This proxy will keep postgres and orientdb syncronized +# When some client call UserRepositoryProxy, it will delegate the missing methods for ActiveRecord User model +module RepositoriesProxy + + def learning_object_repository + application_repository.for(:learning_object) + end + + def attribute_repository + application_repository.for(:attribute) + end + + def subject_repository + application_repository.for(:subject) + end + + def collection_repository + application_repository.for(:collection) + end + + def institution_repository + application_repository.for(:institution) + end + + def carousel_repository + application_repository.for(:carousel) + end + + def main_page_repository + application_repository.for(:mainPage) + end + + def user_repository + application_repository.for(:user) + end + + private + + def application_repository + Portalmec::Application.repository + end + +end diff --git a/app/repositories/user_repository_proxy.rb b/app/repositories/user_repository_proxy.rb index 94e18c596c39b2349b66304edb9fae371caa0bd8..27643d6e0d5d88182d8f86ba33e35e009557f805 100644 --- a/app/repositories/user_repository_proxy.rb +++ b/app/repositories/user_repository_proxy.rb @@ -24,6 +24,14 @@ class UserRepositoryProxy orientdb_user_repository.destroy_graph_node user end + def save(user) + user.save + end + + def save!(user) + user.save! + end + def method_missing(method_name, *arguments, &block) User.send(method_name, *arguments, &block) end diff --git a/app/views/collections/_collection.html.erb b/app/views/collections/_collection.html.erb index eaa86d05f3c146f5e0d2ee4a60c91c7413fd055d..0688d28bd7fde662a155ec4953731a16b17c2685 100644 --- a/app/views/collections/_collection.html.erb +++ b/app/views/collections/_collection.html.erb @@ -1,31 +1,5 @@ <div class="row collections"> - <h2><%= title %></h2> - - <% learning_objects.each do |learning_object| %> - <!-- item --> - <div class="col-sm-4"> - <div class="row"> - <h4><b><%= learning_object.categories %></b></h4> - - <div class="object-vertical"> - <div class="panel"> - <div> - <img src="http://dummyimage.com/250x150/363336/fff" alt="dummy image" class="img-responsive"> - </div> - <div class="panel-body"> - <h4 class="media-heading"><%= learning_object.name %></h4> - <span class="glyphicon glyphicon-eye-open"> <%= learning_object.views %> </span> - <span class="glyphicon glyphicon-star">4,5 </span> - <span>Por <a>Usuário </a></span> - </div> - </div> - </div> - <p> - <a href="#">Ver Mais</a> - </p> - </div> - </div> - <!-- /item --> - <% end %> + <h2><%= collection.title %></h2> + <p><%= collection_length collection %></p> </div> \ No newline at end of file diff --git a/app/views/collections/_create.html.erb b/app/views/collections/_create.html.erb index a0f48962395b5723585e9d761128bd67af7b5de0..cf67f6c19e68f176968fd05e7e54c15804fdd47b 100644 --- a/app/views/collections/_create.html.erb +++ b/app/views/collections/_create.html.erb @@ -1,7 +1,7 @@ <a href="#" id="create_collection_popover">Criar coleção</a> <div id="create_collection_popover_content" style="display: none"> - <%= render 'form' %> + <%= render 'collections/form' %> </div> <div id="create_collection_popover_title" style="display: none"> diff --git a/app/views/collections/_form.html.erb b/app/views/collections/_form.html.erb index aaa75f9e1a311115f098aaff59ed87f318c69001..7330b0254f3ba93c7b437ec76db29a8ae8689ffb 100644 --- a/app/views/collections/_form.html.erb +++ b/app/views/collections/_form.html.erb @@ -1,12 +1,14 @@ -<form> - <label>Nome da coleção</label> - <input type='text' style="width:250px"/> +<%= form_for @collection do |f| %> - <label>Privacidade</label> - <select> - <option>Público</option> - <option>Somente seguidores</option> - </select> + <%= f.label :title %> + <%= f.text_field :title, required: true, style: 'width: 250px;' %> - <input type="submit"/> -</form> \ No newline at end of file + <%= f.label :privacy %> + <select name="collection[privacy]"> + <option value="public">Público</option> + <option value="followers">Meus seguidores</option> + <option value="only_me">Somente eu</option> + </select> + + <%= f.submit %> +<% end %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5974f076c8ed56f498f2588ac3fa2c65fd02e7b7..8979487f8cb3a05fdfa61df8c974fc4a2bda1e87 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,7 @@ <head> <title>PortalMEC</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,700,500' rel='stylesheet' type='text/css'> + <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700' rel='stylesheet' type='text/css'> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <meta property="creator.productor" content="http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/1"> diff --git a/app/views/learning_objects/_actions_buttons.html.erb b/app/views/learning_objects/_actions_buttons.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..23ca78e5048d333ba161b35bab64650b0db67b75 --- /dev/null +++ b/app/views/learning_objects/_actions_buttons.html.erb @@ -0,0 +1,5 @@ +<div class="learning-object-actions"> + <%= render 'learning_objects/like_button' %> + <%= render 'learning_objects/bookmarks_button' %> + <%= render 'learning_objects/collections_button' %> +</div> \ No newline at end of file diff --git a/app/views/learning_objects/_bookmarks_button.html.erb b/app/views/learning_objects/_bookmarks_button.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..69513ca105d96133c02c12a670b1df4613833921 --- /dev/null +++ b/app/views/learning_objects/_bookmarks_button.html.erb @@ -0,0 +1,3 @@ +<button type="button" class="btn btn-default btn-xs" data-toggle="button" aria-pressed="false" autocomplete="off" title="Adicionar aos favoritos"> + <span class="glyphicon glyphicon-bookmark" aria-hidden="true"></span> +</button> \ No newline at end of file diff --git a/app/views/learning_objects/_collections_button.html.erb b/app/views/learning_objects/_collections_button.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..24ff0d56ec818d514e8ca1889900edcbc49748f2 --- /dev/null +++ b/app/views/learning_objects/_collections_button.html.erb @@ -0,0 +1,8 @@ +<button type="button" class="btn btn-default btn-xs add_to_collection" data-toggle="button" aria-pressed="false" autocomplete="off" title="Adicionar as coleções"> + <span class="glyphicon glyphicon-list" aria-hidden="true"></span> +</button> + +<div id="collections_list_popover" style="display: none; z-index: 999;"> + <a href="#">Segundo ano - B</a> + <a href="#">Terceiro ano - A</a> +</div> \ No newline at end of file diff --git a/app/views/learning_objects/_learning_object_horizontal.erb b/app/views/learning_objects/_learning_object_horizontal.erb index 31a37eebdc2e64e6095f8988119062c251c42c63..504d5190d3011f9d9503724c15edb159b87c8e7f 100644 --- a/app/views/learning_objects/_learning_object_horizontal.erb +++ b/app/views/learning_objects/_learning_object_horizontal.erb @@ -1,27 +1,32 @@ +<% link = learning_object_path(id: learning_object.id) %> <div class="learning-object-horizontal"> <div class="media"> <div class="media-left media-middle"> - <a href="#"> - <img src="http://dummyimage.com/250x150/363336/fff" alt='dummy image'> - </a> + <div class="learning-object-thumbnail"> + <%= link_to link do + learning_object_thumbnail learning_object + end %> + + <% if user_signed_in? %> + <%= render 'learning_objects/actions_buttons' %> + <% end %> + </div> </div> + <div class="media-body"> - <a href="<%= learning_object_path(id: learning_object.id) %>"> - <% if learning_object.name.nil? %> - <h4 class="media-heading">Sem TÃtulo</h4> - <% else %> - <h4 class="media-heading"><%= learning_object.name %></h4> - <% end %> - </a> - <span>Por <a>Usuário </a></span><br/> - <span class="glyphicon glyphicon-eye-open"><%= learning_object.views %> </span> - <span class="glyphicon glyphicon-star"><%= learning_object.likes %> </span><br> + <%= link_to link do %> + <h4><%= learning_object_title learning_object %></h4> + <% end %> + + <span>Por <%= link_to 'João', '#' %></span><br/> + <span class="glyphicon glyphicon-eye-open"><%= learning_object.views %></span> + <span class="glyphicon glyphicon-star"><%= learning_object.likes %></span><br> <% unless learning_object.description.nil? %> <%= learning_object.description %> <br/> <% end %> <br/> - Em<b> <%= show_categories learning_object.categories %></b> + <b><%= ("Em " + show_categories(learning_object.categories)) unless learning_object.categories.nil? %></b> </div> </div> </div> diff --git a/app/views/learning_objects/_learning_object_vertical.erb b/app/views/learning_objects/_learning_object_vertical.erb index ff0bc2740338a08f42eda2dc7754a8732f515cbe..7e6887797cf178618594c96f7c20502db68c7043 100644 --- a/app/views/learning_objects/_learning_object_vertical.erb +++ b/app/views/learning_objects/_learning_object_vertical.erb @@ -1,14 +1,15 @@ <div class="learning-object-vertical"> <div class="panel"> - <div> - <img src="http://dummyimage.com/250x150/363336/fff" alt='dummy image' class="img-responsive"> + <div class="learning-object-thumbnail"> + <%= link_to learning_object_path(id: learning_object.id) do + learning_object_thumbnail learning_object + end %> + <% if user_signed_in? %> + <%= render 'learning_objects/actions_buttons' %> + <% end %> </div> <div class="panel-body"> - <% if learning_object.name.nil? %> - <h4 class="media-heading">Sem TÃtulo</h4> - <% else %> - <h4 class="media-heading"><%= learning_object.name %></h4> - <% end %> + <h4 class="media-heading"><%= learning_object_title(learning_object) %></h4> <span class="glyphicon glyphicon-eye-open"><%= learning_object.views %> </span> <span class="glyphicon glyphicon-star"><%= learning_object.likes %> </span> <span>Por <a>Usuário </a></span> diff --git a/app/views/learning_objects/_like_button.html.erb b/app/views/learning_objects/_like_button.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..b59543135607e64f8cf73b6360e17d1d8850f346 --- /dev/null +++ b/app/views/learning_objects/_like_button.html.erb @@ -0,0 +1,3 @@ +<button type="button" class="btn btn-primary btn-xs" data-toggle="button" aria-pressed="false" autocomplete="off" title="Gostei"> + <span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span> +</button> \ No newline at end of file diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index 1c485edad72b11ac3778fb4538becfa23f8340c5..efb4720e63e728d46db928602f74678594d438a2 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -1,4 +1,4 @@ -<h1><%= @learning_object.name %></h1> +<!-- <h1><%= @learning_object.name %></h1> <ul> <li><b>Autor: </b><%= @learning_object.get_metadata_value_of("dc.contributor.author") %></li> @@ -21,4 +21,268 @@ <%= link_to "Curtir", like_learning_object_path(@learning_object.id_dspace), method: :post, remote: true %> -<% end %> +<% end %> --> + +<div class="row learning-object"> + <div class="col-md-7"> + <%= + if (@learning_object.thumbnail == "thumbnai") + image_tag 'learning-object-preview-large.png', class: "thumbnail" + else + image_tag @learning_object.thumbnail, class: "thumbnail" + end + %> + <div class="stats"> + <span class="glyphicon glyphicon-eye-open"><%= @learning_object.views %> </span> + <span class="glyphicon glyphicon-star"><%= @learning_object.likes %> </span> + </div> + <h2 class="title"><%= @learning_object.name %></h2> + <% unless @learning_object.description.nil? %> + <p class="description"><%= @learning_object.description %></p> + <% end %> + <span class="category"><%= ("Em " + show_categories(@learning_object.categories)) unless @learning_object.categories.nil? %></span> + </div> + <div class="col-md-5"> + <div class="rightbar"> + <div class="media"> + <div class="media-left"> + <a href="#"> + <img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/> + </a> + </div> + <div class="media-body"> + <h5>Adicionado por</h5> + <h3 class="media-heading"><%= @learning_object.get_metadata_value_of("dc.contributor.author") %></h3> + </div> + </div> + <div class="rating-panel"> + <p>O que você achou deste arquivo?</p> + <div class="rating"> + <span class="starRating"> + <input id="rating5" name="rating" type="radio" value="5"> + <label for="rating5">5</label> + <input id="rating4" name="rating" type="radio" value="4"> + <label for="rating4">4</label> + <input checked id="rating3" name="rating" type="radio" value="3"> + <label for="rating3">3</label> + <input id="rating2" name="rating" type="radio" value="2"> + <label for="rating2">2</label> + <input id="rating1" name="rating" type="radio" value="1"> + <label for="rating1">1</label> + </span> + </div> + </div> + <div class="actions"> + <div class="col-md-3 action"> + <%= image_tag "icons/download.png", alt: "Download do objeto" %> + <h6>salvar no computador</h6> + </div> + <div class="col-md-3 action"> + <%= image_tag "icons/collection-add.png", alt: "Adicionar à coleção" %> + <h6>adicionar à coleção</h6> + </div> + <div class="col-md-3 action"></div> + <div class="col-md-3 action"> + <%= image_tag "icons/report-circle.png", alt: "Denunciar objeto" %> + <h6>denunciar objeto</h6> + </div> + </div> + </div> + </div> +</div> + +<!-- <div class="container-fluid"> + <div class="container-fluid"> + <div class="row"> + <div class="col-sm-6"> + <a href=""> + <img alt="<%=@learning_object.name %>" class="img-responsive" height="550" src="<%= @learning_object.thumbnail %>" width="600"> + </a> + <p> + <h1><%= @learning_object.name %></h1> + </p> + </div> + <div class="col-sm-6"> + <div class="col-sm-12"> + <div class="row"> + <div class="col-md-12">Adicionado por: + <h1> + <img class="img-circle" src="images/user.jpg"> + <a href="autor.php"><%= @learning_object.get_metadata_value_of("dc.contributor.author") %></a> + </h1> + </div> + </div><br/> + <%= @learning_object.get_metadata_value_of("dc.description") %> + </div> + <div class="col-sm-12"> + <br/> + <table class="table"> + <tr> + <td>Avalie:</td> + <td>Total curtir:</td> + <td>Visualizações:</td> + <td>Total Downloads: + </td> + </tr> + <tr> + <td> + + () + </td> + <td> + <%= @learning_object.likes %></td> + <td><%= @learning_object.views %></td> + <td>-</td> + </tr> + </table><br/> + <!--div class="pull-right"--> + <!-- <div style="text-align: center;"> + <a class="btn btn-primary" href="#">Download</a> + </div> + </div> + </div> + </div> + <br/><br/> + <div class="row"> + <div class="col-sm-8"> + <ul> + <li> + <b>Autor: + </b><%= @learning_object.get_metadata_value_of("dc.contributor.author") %></li> + <li> + <b>Tipo: + </b><%= @learning_object.get_metadata_value_of("dc.type") %></li> + <li> + <b>Data: + </b><%= @learning_object.get_metadata_value_of("dc.date.available") %></li> + <li> + <b>Linguagem: + </b><%= @learning_object.get_metadata_value_of("dc.language") %></li> + <li> + <b>Metadados: + </b> + </li> + </ul> + <table class="table table-striped"> + <% @learning_object.metadata.each do |m| %> + <tr > + <th > + <span ><%= "#{m["key"]}:" %></span > + </th> + <td > + <%= "#{m["value"]}" %></td> + </tr> + <% end %> + </table> + <br/> + <% if user_signed_in? %> + <%= link_to "Curtir", + like_learning_object_path(@learning_object.id_dspace), + method: :post, remote: true %> + <% end %> + <br/> --> + <!-- <div class="row"> + <div class="col-md-12"> + <h1>Comentários</h1> + </div> + </div> + + <div class="row"> + <div class="col-md-12"> + <div class="media"> + <form action="?f=addComment" method="POST"> + <div class="media-left"> + <label></label> + <a href="#"><img alt="<img_usuario>" class="media-object" src="images/user.jpg" width="64"></a> + </div> + <div class="media-body"> + <label for="comment">Comentário:</label> + <textarea class="form-control" name="text" rows="2" width=200px></textarea> + </br> + <div align="right"><input class="btn btn-success" type="submit" value="Enviar Comentário"></div> + </div> + </form> + </div> + </div> + </div> + </br> + <div class="row"> + <div class="col-md-1"> + <img class="img-circle" height="50" src="images/user.jpg" width="50"> + </div> + <div class="col-md-11"> + <h4>Nome Sobrenome</h4> + Coment ... + </div> + </div> + <hr> + + <div class="row"> + <div class="col-md-1"> + <img class="img-circle" height="50" src="images/user.jpg" width="50"> + </div> + <div class="col-md-11"> + <h4>Nome Sobrenome</h4> + Coment ... + </div> + </div> + <hr> + <div class="row"> + <div class="col-md-1"> + <img class="img-circle" height="50" src="images/user.jpg" width="50"> + </div> + <div class="col-md-11"> + <h4>Nome Sobrenome</h4> + Coment ... + </div> + </div> + <hr> + <div class="row"> + <div class="col-md-12"> + <center> + <a class="btn btn-primary" href="#">Ver mais...</a> + </center> + </div> + </div> + <br/> + + </div> --> + <!--arquivos relacionados--> + <!-- <div class="col-sm-4"> + <div class="row"> + <div class="col-md-12"> + <h1> + Arquivos relacionados + </h1> + </div> + </div> + <%# @related_objects.each do |o| %> + <div class="row"> + <div class="col-md-12"> + <div class="itemvert"> + <center><img class="img-responsive" height="180" src="<%#= o.thumbnail %>" width="320"> + <h1> + <%#= o.name %> + </h1> + <p> + <span aria-hidden="true" class="glyphicon glyphicon-search"></span>(<%#= o.views %>) + <img height="15" src="star-on.svg" width="15"> + <img height="15" src="star-on.svg" width="15"> + <img height="15" src="star-on.svg" width="15"> + <img height="15" src="star-on.svg" width="15"> + <img height="15" src="star-on.svg" width="15"></span>(10,0)<br/> + <a href="autor.php"><img class="img-circle" height="32" src="images/user.jpg" width="32"> + por Jonas</a> + </p> + </center> + </div> + </div> + </div><hr> + <%# end %> + </div> --> +<!-- </div> +<br/> +</div> +<!-- container fluid --> +<!-- </div> --> +<!-- /container --> diff --git a/app/views/management/carousels/_form.html.erb b/app/views/management/carousels/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9c4fa033325ca034ee30381bc9fdc017379a6001 --- /dev/null +++ b/app/views/management/carousels/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for([:management, @carousel], html: {class: 'ls-form row'}) do |f| %> + + <% if @carousel.errors.any? %> + <div class="ls-alert-danger"> + <h2><%= pluralize(@carousel.errors.count, "erro") %> <%= "happened".pluralize(@carousel.errors.count) %>:</h2> + <ul> + <% @carousel.errors.full_messages.each do |message| %> + <li><%= message %></li> + <% end %> + </ul> + </div> + <% end %> + + <fieldset> + <label class="ls-label col-md-3"> + <b class="ls-label-text">TÃtulo</b> + + <p>Digite o titulo deste destaque</p> + <%= f.text_field :title, {required: true} %> + </label> + <label class="ls-label col-md-5"> + <b class="ls-label-text">URL</b> + + <p>Digite a URL que o usuário será redirecionado</p> + <%= f.url_field :url, {required: true} %> + </label> + + <label class="ls-label col-md-5"> + <b class="ls-label-text">Imagem</b> + + <p>Escolha uma imagem para o destaque</p> + <%= f.file_field :image %> + </label> + </fieldset> + + <div class="ls-actions-btn"> + <button class="ls-btn">Salvar</button> + <%= link_to "Cancelar", management_carousels_path,class: "ls-btn-danger"%> + </div> + +<% end %> diff --git a/app/views/management/carousels/edit.html.erb b/app/views/management/carousels/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..40381273a38d67c2d1aedb64c2a22b9951ae68ef --- /dev/null +++ b/app/views/management/carousels/edit.html.erb @@ -0,0 +1,8 @@ +<h1 class="ls-title-intro ls-ico-users">Carrossel</h1> + +<ol class="ls-breadcrumb"> + <li><%= link_to 'Carrosséis', management_carousels_path %></li> + <li>Administrar</li> +</ol> + +<%= render 'form' %> diff --git a/app/views/management/carousels/index.html.erb b/app/views/management/carousels/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9b794145170bb7ddf7b8e5dca87acc0d1301f954 --- /dev/null +++ b/app/views/management/carousels/index.html.erb @@ -0,0 +1,45 @@ +<h1 class="ls-title-intro ls-ico-users">Carrossel</h1> + +<a href="<%= new_management_carousel_path %>" class="ls-btn-primary" aria-expanded="false" role="combobox">Cadastrar + novo</a> +<table class="ls-table"> + <thead> + <tr> + <th> + Imagem + </th> + <th>TÃtulo</th> + <th> + URL + </th> + <th> + </th> + <th></th> + </tr> + </thead> + <tbody> + + <% @carousels.each do |c| %> + <tr> + <td> + <%= image_tag c.image.url(:thumbnail) %> + </td> + + <td> + <%= c.title %> + </td> + <td> + <%= c.url %> + </td> + + <td class="ls-txt-right ls-regroup"> + <%= link_to 'Modificar', edit_management_carousel_path(c) %> + </td> + <td> + <%= link_to 'Excluir', management_carousel_path(c), {method: :delete, data: {confirm: 'Tem certeza que deseja excluir?'}, title: 'Apagar usuário', class: 'ls-color-danger', role: 'option'} %> + </td> + </tr> + <% end %> + + </tbody> +</table> diff --git a/app/views/management/carousels/new.html.erb b/app/views/management/carousels/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f7a51f48a7c69b3a276a616c5a04c82380e35aa5 --- /dev/null +++ b/app/views/management/carousels/new.html.erb @@ -0,0 +1,8 @@ +<h1 class="ls-title-intro ls-ico-users">Carrossel</h1> + +<ol class="ls-breadcrumb"> + <li><%= link_to 'Carrosséis', management_carousels_path %></li> + <li>Novo Carrossel</li> +</ol> + +<%= render 'form' %> diff --git a/app/views/management/highlights/_form_delete.html.erb b/app/views/management/highlights/_form_delete.html.erb deleted file mode 100644 index 58312ed0bc411e780c6fc336fcdda0084da9717f..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/_form_delete.html.erb +++ /dev/null @@ -1,33 +0,0 @@ - -<body> - -<div> - <class="ls-info-header"> - <class="ls-title-2"><h3>Remover destaque</h3><br> - - - - <%= form_tag(:action => "destroy", :method => "get") do %> - <fieldset> -<!-- Exemplo com Radio button --> - <div class="ls-label col-md-5"> - <p>Escolha os destaques a remover:</p> - <% @highlights.each do |highlight| %> - <label class="ls-label-text"> - <input type="checkbox" name="id[]" value= <%= highlight['@rid'] %>> - <%= highlight['name'] %> - </label> - <%end%> - </div> - </fieldset> - - - <div class="ls-actions-btn"> - <%= submit_tag "Salvar", class: "ls-btn" %> - <%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %> - </div> - <%end%> -</div> - - -</body> diff --git a/app/views/management/highlights/_form_new.html.erb b/app/views/management/highlights/_form_new.html.erb deleted file mode 100644 index ad4e8e5092da2ff313ebd84d61f3854f5e521879..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/_form_new.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -<body> - <div> - <!-- - <class="ls-info-header"> - <class="ls-title-2"><h3>Adicionar destaque</h3><br> - - <form action="" class="ls-form row"> - <fieldset> - <label class="ls-label col-md-3"> - <b class="ls-label-text">TÃtulo</b> - <p>Digite o tÃtulo do destaque</p> - <input type="text" name="name" placeholder="TÃtulo" required > - </label> - <label class="ls-label col-md-4"> - <b class="ls-label-text">URL</b> - <p>Cole a url do destaque no portal</p> - <input type="url" name="url" placeholder="URL do destaque no portal" required > - </label> - - </fieldset> - </form> ---> - - - - <%= form_tag( :action => "create", method: "post") do %> - <%= label_tag :name, "TÃtulo do destaque" %><br><br> - <%= text_field_tag :name,'', placeholder: "tÃtulo " %> - <br><br><br> - - <%= label_tag :url, "URL da coleção no portal" %><br><br> - <%= text_field_tag :url, '', placeholder: "url" %> - <%= submit_tag "Salvar", class: "ls-btn" %> - - <% end %> - - -<div class="ls-actions-btn"> - - <%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %> - -</div> -</body> diff --git a/app/views/management/highlights/delete.html.erb b/app/views/management/highlights/delete.html.erb deleted file mode 100644 index d1a58f61228d1a95c4808227b39ce450e7f9f6cc..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/delete.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li><%= link_to "Destaques", management_highlights_index_path %></li> - <li> Remover </li> -</ol> -<br> - -<%= render 'form_delete' %> diff --git a/app/views/management/highlights/index.html.erb b/app/views/management/highlights/index.html.erb deleted file mode 100644 index 36865eb4f5d4c001462b1fc26df0c992d3d85ac0..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/index.html.erb +++ /dev/null @@ -1,45 +0,0 @@ - - - -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li> Destaques </li> -</ol> -<br> - -<div> - <header class="ls-info-header"> - <h2 class="ls-title-3">Destaques</h2> - <p class="ls-float-right ls-float-none-xs ls-small-info"> <strong><%= Date.today.to_s %></strong></p> - </header> - -</div> - - - - - <div class="ls-list-title "> - <b>Destaques atuais no carrosel:</b> - </div> - <div class="ls-list-description"> - <ul> - <% if @highlights.present? %> - <% @highlights.each do |highlight| %> - <br> - <li> <%= highlight['name'] %></li> - <% end %> - <% else %> - <li> - Não existe nenhuma destaque ainda. - </li> - <%end%> - </ul> - </div> - - - -<br><br><br> -<%= link_to "Adicionar destaques", management_highlights_new_path, class: "ls-btn ls-btn-lg" %> - - -<%= link_to "Remover destaques", management_highlights_delete_path, class: "ls-btn ls-btn-lg" %> diff --git a/app/views/management/highlights/new.html.erb b/app/views/management/highlights/new.html.erb deleted file mode 100644 index 9356f7932651a572f51416b85b2d8b48e9978c02..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/new.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li><%= link_to "Destaques", management_highlights_index_path %></li> - <li> Novo </li> -</ol> -<br> - -<%= render 'form_new' %> diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 46f39ee39908c84a87445daf64decea7d72434ff..ec3d57d734be38cb52528399d6c48c99eb409043 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -1,26 +1,3 @@ -<script type="text/javascript"> - $(document).ready(function () { - $(".select-tag-container").select2(); - - var runDropdown = function (element) { - if ($(element).next().is(':hidden')) { - $('> .caret', element).addClass('caret-up'); - $(element).next().slideDown(); - } - else { - $('> .caret', element).removeClass('caret-up'); - $(element).next().slideUp(); - } - }; - - runDropdown($('#nestedAccordion .dropdown')); - - $('#nestedAccordion .dropdown').click(function () { - runDropdown(this); - }); - }); -</script> - <div class="row"> <div class="col-sm-4 search-sidebar"> <!-- <h2>Busca Avançada</h2> --> @@ -34,7 +11,7 @@ </div> </div> --> - <div id="nestedAccordion"> + <div class="nestedAccordion"> <h3 class="dropdown open">Matérias<span class="caret caret-align-right"/></h3> <div class="dropdown-element"> @@ -293,9 +270,9 @@ <input type="text" name="ano2" size="8"> - <input type="text" name="ano2" size="8"> </div> </div> - <!-- fim div id="nestedAccordion"--> + <!-- fim div class="nestedAccordion"--> - <div id="nestedAccordion"> + <div class="nestedAccordion"> <h3 class="dropdown">Pesquisa Avançada<span class="caret caret-align-right"/></h3> <form method="get"> diff --git a/app/views/shared/application/_header.html.erb b/app/views/shared/application/_header.html.erb index a36456d98142a784c40f32619fc898fc5a59ad84..0936cdd336eb45b8b6955f85b302eb5ca5798356 100644 --- a/app/views/shared/application/_header.html.erb +++ b/app/views/shared/application/_header.html.erb @@ -2,10 +2,14 @@ <div class="barra-brasil"> <div class="container"> <div id="barra-brasil"> - <ul id="menu-barra-temp" style="list-style:none;"> - <li style="display:inline; float:left;padding-right:10px; margin-right:10px; border-right:1px solid #EDEDED"><a href="http://brasil.gov.br" style="font-family:sans,sans-serif; text-decoration:none; color:white;">Portal do Governo Brasileiro</a></li> - <li><a style="font-family:sans,sans-serif; text-decoration:none; color:white;" href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualize sua Barra de Governo</a></li> - </ul> + <ul id="menu-barra-temp" style="list-style:none;"> + <li style="display:inline; float:left;padding-right:10px; margin-right:10px; border-right:1px solid #EDEDED"> + <a href="http://brasil.gov.br" style="font-family:sans,sans-serif; text-decoration:none; color:white;">Portal + do Governo Brasileiro</a></li> + <li> + <a style="font-family:sans,sans-serif; text-decoration:none; color:white;" href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualize + sua Barra de Governo</a></li> + </ul> </div> </div> </div> @@ -16,8 +20,9 @@ <div class="col-md-3 logo-container"> <div class="logo"> <%= link_to root_path do %> - <%= image_tag image_path("logo.png"), class: "logo-image" %><br/> - <h3>CONTEÚDO EDUCACIONAL</h3> + <%= image_tag image_path("logo.png"), class: "logo-image" %><br/> + + <h3>CONTEÚDO EDUCACIONAL</h3> <% end %> </div> </div> @@ -33,6 +38,7 @@ <form action="/search" method="get"> <div class="input-group" id="search"> <input type="text" placeholder="buscar" class="form-control" name="qry"> + <div class="input-group-btn"> <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button> </div> @@ -44,24 +50,24 @@ <div class="col-md-3 status-text"> <% if user_signed_in? %> - <div class="media"> - <div class="media-body"> - <h2 class="media-heading"><%= link_to current_user.name.split(" ").first, edit_user_registration_path %></h2> - <h4><%= link_to 'sair', destroy_user_session_path, method: 'delete', class: "quit-link" %></h4> - </div> - <div class="media-right"> - <a href="#"> - <img class="user-image" src="<%= current_user.avatar.url(:thumb) %>" alt="Foto do usuário"/> - </a> + <div class="media"> + <div class="media-body"> + <h2 class="media-heading"><%= link_to current_user.name.split(" ").first, edit_user_registration_path %></h2> + <h4><%= link_to 'sair', destroy_user_session_path, method: 'delete', class: "quit-link" %></h4> + </div> + <div class="media-right"> + <a href="#"> + <img class="user-image" src="<%= current_user.avatar.url(:thumb) %>" alt="Foto do usuário"/> + </a> + </div> </div> - </div> <% else %> - <div class="media"> - <div class="media-body"> - <h2 class="media-heading"><%= link_to 'entre', new_user_session_path %></h2> - <h4>ou <%= link_to 'cadastre-se', new_user_registration_path, class: "register-link" %></h4> + <div class="media"> + <div class="media-body"> + <h2 class="media-heading"><%= link_to 'entre', new_user_session_path %></h2> + <h4>ou <%= link_to 'cadastre-se', new_user_registration_path, class: "register-link" %></h4> + </div> </div> - </div> <% end %> </div> </div> @@ -75,9 +81,8 @@ <li class="nav-button nav-button-first"><h3><%= link_to 'Assuntos' %></h3></li> <li role="separator" class="divider"></li> <li class="dropdown nav-button"> - <h3> - <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">NÃveis de Ensino <span class="caret" /></a> - </h3> + <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">NÃveis de + Ensino <span class="caret"/></a> <ul class="dropdown-menu"> <li> <div class="row" style="width: 400px;"> @@ -110,6 +115,40 @@ <li role="separator" class="divider"></li> <li class="nav-button"><h3><%= link_to 'Contato', contact_path %></h3></li> <li role="separator" class="divider"></li> + <li class="dropdown nav-button"> + <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">Links + úteis <span class="caret"/></a> + <ul class="dropdown-menu"> + <li> + <div class="row" style="width: 400px;"> + <ul class="list-unstyled col-md-6 col-md-offset-1"> + <li><b>Portais nacionais e internacionais</b></li> + <li role="separator" class="divider"></li> + <li><a href="">Portais Educacionais</a></li> + <li><a href="">Museus</a></li> + <li><a href="">Bibliotecas</a></li> + <li><a href="">Revistas</a></li> + <li><a href="">Projetos Inovadores</a></li> + <li><a href="">Jornais</a></li> + <li><a href="">Projeto de escolas</a></li> + <li><a href="">Um computador por aluno</a></li> + <li><a href="">Geoprocessamento</a></li> + <li><a href="">Prêmio Professores do Brasil</a></li> + <li><a href="">Capacitação ProInfo Integrado</a></li> + </ul> + <ul class="list-unstyled col-md-5"> + <li><b>Visite também</b></li> + <li role="separator" class="divider"></li> + <li><a href="">DomÃnio Público</a></li> + <li><a href="">E-ProInfo</a></li> + <li><a href="">Objetos Educacionais</a></li> + <li><a href="">Plataforma Freire</a></li> + <li><a href="">TV Escola</a></li> + </ul> + </div> + </li> + </ul> + </li> </ul> </div> </div> diff --git a/app/views/shared/application/_object_single.html.erb b/app/views/shared/application/_object_single.html.erb deleted file mode 100644 index 27de179726caf4aa86256bd361cadf7f76e49fc9..0000000000000000000000000000000000000000 --- a/app/views/shared/application/_object_single.html.erb +++ /dev/null @@ -1,49 +0,0 @@ -<!--<%=debug obj%>--> - -<div class="row"> - <div class="col-sm-3"> - <a href="app/assets/images/logo.png" class="thumbnail"> - <p><% unless obj["title"].nil? %> - <p><%= obj["title"][0] %></p> - <% end %> - </p> - <!-- <%= link_to image_tag("logo.png", :class => "img-responsive"), :class => "thumbnail" %><img src="app/assets/images/logo.png" alt="" width="284" height="213">--> - <%= image_tag("logo.png") %> - </a> - </div> - <div class="col-sm-9"> - <div class="col-sm-12"> - <% unless obj["dc.description"].nil? %> - <%= obj["dc.description"][0] %> - <% end %> - </div> - <div class="col-sm-12"> - <div align="right"><%= link_to "Ver mais...", learning_object_path(obj["search.resourceid"]), :class => "btn btn-primary" %></div> - <br/> - <table class="table "> - <tr> - <td class="stars">Avaliações:</td><td>Postado por:</td><td class="visualis">Visualizações:</td> - </tr> - <tr> - <td> - <span class="starRating"> - <input id="rating5" type="radio" name="rating" value="5" disabled> - <label for="rating5">5</label> - <input id="rating4" type="radio" name="rating" value="4" checked disabled> - <label for="rating4">4</label> - <input id="rating3" type="radio" name="rating" value="3" disabled> - <label for="rating3">3</label> - <input id="rating2" type="radio" name="rating" value="2" disabled> - <label for="rating2">2</label> - <input id="rating1" type="radio" name="rating" value="1" disabled> - <label for="rating1">1</label> - </span> - () - </td> - <td><%= link_to obj["author"][0] %> Há ... anos</td> - <td>333</td> - </tr> - </table> - </div> - </div> - </div> diff --git a/app/views/shared/application/_object_tag.html.erb b/app/views/shared/application/_object_tag.html.erb deleted file mode 100644 index c117569976df7ec75f87225f39877e2f6252d65c..0000000000000000000000000000000000000000 --- a/app/views/shared/application/_object_tag.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<!--<%=debug obj%>--> - -<div class="row"> - <div class="col-sm-3"> - <a href="app/assets/images/logo.png" class="thumbnail"> - <p><%= obj.name %></p> - <!-- <%= link_to image_tag("logo.png", :class => "img-responsive"), :class => "thumbnail" %><img src="app/assets/images/logo.png" alt="" width="284" height="213">--> - <%= image_tag("logo.png") %> - </a> - </div> - <div class="col-sm-9"> - <div class="col-sm-12"> - <%= obj.description %> - </div> - <div class="col-sm-12"> - <div align="right"><%= link_to "Ver mais...", learning_object_path(obj.id_dspace), :class => "btn btn-primary" %></div> - <br/> - <table class="table "> - <tr> - <td class="stars">Avaliações:</td><td>Postado por:</td><td class="visualis">Visualizações:</td> - </tr> - <tr> - <td> - <span class="starRating"> - <input id="rating5" type="radio" name="rating" value="5" disabled> - <label for="rating5">5</label> - <input id="rating4" type="radio" name="rating" value="4" checked disabled> - <label for="rating4">4</label> - <input id="rating3" type="radio" name="rating" value="3" disabled> - <label for="rating3">3</label> - <input id="rating2" type="radio" name="rating" value="2" disabled> - <label for="rating2">2</label> - <input id="rating1" type="radio" name="rating" value="1" disabled> - <label for="rating1">1</label> - </span> - () - </td> - <td><%= link_to "<<Autor>>" %> Há ... anos</td> - <td><%= obj.views %></td> - </tr> - </table> - </div> - </div> - </div> diff --git a/app/views/shared/management/_nav_menu.html.erb b/app/views/shared/management/_nav_menu.html.erb index 3b8b8e725bf19176df73c3708fbb023960be7485..d0d4771c0081723c44365d60045adc66b0270470 100644 --- a/app/views/shared/management/_nav_menu.html.erb +++ b/app/views/shared/management/_nav_menu.html.erb @@ -1,17 +1,17 @@ <nav class="ls-menu"> <ul> <li><%= link_to "InÃcio", management_root_path, class: 'ls-ico-home' %></li> - <li><%= link_to "Objetos em destaque", management_highlights_path, class: 'ls-ico-star' %> + <li><%= link_to "Objetos em destaque", management_carousels_path, class: 'ls-ico-star' %> <li> <li class="ls-submenu"> <a href="#" class="ls-ico-stats">EstatÃsticas</a> <ul role="menu"> - <li><%= link_to "Geral", management_index_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Usuários", management_users_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Coleções", management_collections_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Downloads", management_downloads_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Acessos", management_accesses_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Geral", management_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Usuários", users_management_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Coleções", collections_management_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Downloads", downloads_management_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Acessos", accesses_management_statistics_path, class: 'ls-submenu-item' %></li> </ul> </li> <li class="ls-submenu"> @@ -25,4 +25,4 @@ <li><%= link_to "Denúncias", '#', class: 'ls-ico-bullhorn' %> <li> </ul> -</nav> \ No newline at end of file +</nav> diff --git a/app/views/shared/management/_user_account.html.erb b/app/views/shared/management/_user_account.html.erb index 6fc0661f8492d67f5b0d11b9e67ec1664982416e..1dcf6fd40effd41a70b48bebd0b2afec2705aa59 100644 --- a/app/views/shared/management/_user_account.html.erb +++ b/app/views/shared/management/_user_account.html.erb @@ -1,7 +1,6 @@ <div data-ls-module="dropdown" class="ls-dropdown ls-user-account"> <a href="#" class="ls-ico-user"> - Carlos Marques - <small>(lstyle)</small> + <%= current_user.name || current_user.email %> </a> <nav class="ls-dropdown-nav ls-user-menu"> <ul> diff --git a/app/views/subjects/index.html.erb b/app/views/subjects/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5d16dbd2375c44be23f42257dde4a1820dd12fc4 --- /dev/null +++ b/app/views/subjects/index.html.erb @@ -0,0 +1,8 @@ +<p id="notice"><%= notice %></p> + +<h1>Listing Subject</h1> + + +<%for subject in @subjects%> + <%= render 'shared/application/object_vertical', object: subject %> +<%end%> diff --git a/app/views/subjects/show.html.erb b/app/views/subjects/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..d3c806d7f6dada08241f3860aaeedf6d3fa844d8 --- /dev/null +++ b/app/views/subjects/show.html.erb @@ -0,0 +1 @@ +<h1><%= @subject.name %></h1> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 2d04b8d963b208f4c7f8abd3a6e7ed6746fba944..006c5610489895d1ee2b6a41c119250ceefd9169 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -8,11 +8,9 @@ </a> </div> <div class="media-body"> - <h4 class="media-heading">Usuário</h4> - <span>nome da instituição</span> - <p> - x items - </p> + <h2 class="media-heading">Usuário</h2> + <h3 class="header-sub">nome da instituição</h3> + <h3 class="header-content">x items</h3> </div> </div> </div> @@ -26,10 +24,8 @@ <div class="col-md-6"> <div class="media"> <div class="media-body"> - <h4 class="media-heading">Arquivos do usuário</h4> - <p> - x items - </p> + <h2 class="media-heading">Arquivos do usuário</h2> + <h4>x items</h4> </div> </div> </div> @@ -37,22 +33,47 @@ </div> </div> + <div class="row learning-object-columns"> + <%= render @objects[0], orientation: "vertical" %> + <%= render @objects[1], orientation: "vertical" %> + <%= render @objects[2], orientation: "vertical" %> + <%= render @objects[0], orientation: "vertical" %> + <%= render @objects[1], orientation: "vertical" %> + <%= render @objects[2], orientation: "vertical" %> + </div> + + <div style="clear: both;"></div> + <div style="float: right;"> + <a href="#">Ver todos</a> + </div> + </div> + + <div class="user-files"> <div class="row"> - <div class="col-md-3"> - <%= render @objects[0], orientation: "vertical" %> - </div> <div class="col-md-6"> - <div class="row"> - <div class="col-md-3"></div> - <div class="col-md-6"> - <%= render @objects[1], orientation: "vertical" %> + <div class="media"> + <div class="media-body"> + <h2 class="media-heading">Coleções</h2> + <h4>x items</h4> </div> - <div class="col-md-3"></div> </div> </div> - <div class="col-md-3"> - <%= render @objects[2], orientation: "vertical" %> + <div class="col-md-6 right-column"> </div> </div> + + <div class="row learning-object-columns"> + <%= render @objects[0], orientation: "vertical" %> + <%= render @objects[1], orientation: "vertical" %> + <%= render @objects[2], orientation: "vertical" %> + <%= render @objects[0], orientation: "vertical" %> + <%= render @objects[1], orientation: "vertical" %> + <%= render @objects[2], orientation: "vertical" %> + </div> </div> </div> + + +<div class="row"> + <%#= render 'collections/create' %> +</div> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 7275f6c893bc8910c135648718c276c2d379aeef..61f5baf9c874a36a4b2bfd853eef62a6269791ce 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -23,12 +23,11 @@ <% highlight_class="item" %> <% end %> <div class="<%= highlight_class %>"> - <%= image_tag 'mecshow_logo.jpg'%> + <%= image_tag highlight.image.url(:larger) %> <div class="container"> <div class="carousel-caption"> - <h1><%= highlight['title'] %></h1> - <p id="carrousel-new-description"><%= highlight['description'] %> </p> - <p><a class="btn btn-lg btn-primary" href=<%= highlight['URL'] %> role="button">Mais informações</a></p> + <h1><%= highlight.title %></h1> + <p><a class="btn btn-lg btn-primary" href=<%= highlight.url %> role="button">Mais informações</a></p> </div> </div> </div> @@ -49,9 +48,7 @@ <% if @General.present? %> <ul class="list-unstyled"> <h2>Destaques</h2> - <% @General.each do |object| %> - <%= render 'shared/application/object_horizontal', object: object %> - <% end %> + <%= render @General, orientation: 'horizontal' %> <% end %> </ul> </div> @@ -69,8 +66,8 @@ <% @Subjects.each do |subject|%> <div class="col-sm-4"> <div class="row"> - <h4><b><%= subject["name"] %></b></h4> - <%= render 'shared/application/object_vertical', object: subject["first_highlight"] %> + <h4><b><%= subject.name %></b></h4> + <%= render subject.highlights.first, orientation: 'vertical'%> <p> <a href="#">Ver Mais</a> </p> @@ -80,4 +77,4 @@ </div> <% end %> </div> -</div> +</div> \ No newline at end of file diff --git a/app/workers/massive_likes_creator_worker.rb b/app/workers/massive_likes_creator_worker.rb new file mode 100644 index 0000000000000000000000000000000000000000..79506a6831d6571a912b2a24990054f0f60ed616 --- /dev/null +++ b/app/workers/massive_likes_creator_worker.rb @@ -0,0 +1,21 @@ +class MassiveLikesCreatorWorker + + include Sidekiq::Worker + include RepositoriesProxy + + def perform(item_id, users_ids) + + item = learning_object_repository.find item_id + + users_ids.each do |user_id| + user = User.find user_id + begin + learning_object_repository.like user, item + rescue + next + end + end + + end + +end diff --git a/app/workers/massive_views_creator_worker.rb b/app/workers/massive_views_creator_worker.rb new file mode 100644 index 0000000000000000000000000000000000000000..a5903a0a87314ecb87074abfc47cf1e90e4ab418 --- /dev/null +++ b/app/workers/massive_views_creator_worker.rb @@ -0,0 +1,21 @@ +class MassiveViewsCreatorWorker + + include Sidekiq::Worker + include RepositoriesProxy + + def perform(item_id, users_ids) + + item = learning_object_repository.find item_id + + users_ids.each do |user_id| + user = User.find user_id + begin + learning_object_repository.increment_views user, item + rescue + next + end + end + + end + +end diff --git a/app/workers/thumbnail_generator_worker.rb b/app/workers/thumbnail_generator_worker.rb new file mode 100644 index 0000000000000000000000000000000000000000..75b809f3f6141524b8a98ee833ccf87476ebb84a --- /dev/null +++ b/app/workers/thumbnail_generator_worker.rb @@ -0,0 +1,58 @@ +class ThumbnailGeneratorWorker + + include Sidekiq::Worker + include RepositoriesProxy + include Thumbnail::Creation + include Thumbnail::Formats + + def perform(learning_object_id) + + item = learning_object_repository.find(learning_object_id) + filename = item.get_bitstream_filename_of "ORIGINAL" + + size = "530x298" + + unless accepted_formats.include? file_format filename + item.thumbnail = default_thumbnail + else + begin + retrieve_link = item.get_bitstream_retrievelink_of "ORIGINAL" + file = download_bitstream(retrieve_link,filename) + rescue + puts "ERROR!!! Some error occurred during file download." + else + item.thumbnail = generate_thumbnail(file,filename,size) + delete_downloaded_bitstream(file) + end + end + + learning_object_repository.update_property(item,"thumbnail",item.thumbnail) + + end + + private + + def delete_downloaded_bitstream(file) + File.unlink(file) if File.exist?(file) + end + + def download_bitstream(url, filename) + output_dir = "/tmp" + + output_file = "#{output_dir}/#{filename}" + + c = Curl::Easy.new(url) + c.ssl_verify_peer = false + c.ssl_verify_host = false + File.open(output_file, 'wb') do |f| + # c.on_progress { |dl_total, dl_now, ul_total, ul_now| + # puts "#{dl_total}, #{dl_now}, #{ul_total}, #{ul_now}"; true + # } + c.on_body {|data| f << data; data.size } + c.perform + end + + return output_file + end + +end diff --git a/config/initializers/repositories/dspace.rb b/config/initializers/repositories/dspace.rb index f2a71dbd217f0bff4b7c836afa4107a2859cbd94..48a75aab0f7308207fba630d98dd22130408b31c 100644 --- a/config/initializers/repositories/dspace.rb +++ b/config/initializers/repositories/dspace.rb @@ -15,4 +15,4 @@ else config = dspace_configs.fetch(Rails.env) set_dspace_config config['host'], config['port'], config['rest_webapp_name'], config['solr_webapp_name'] -end +end \ No newline at end of file diff --git a/config/initializers/repositories/repositories.rb b/config/initializers/repositories/repositories.rb index caebcb6b5995c78904a92585f573b3f540cd2990..f6666e218bec5ea09b18d95b0217612a57577a43 100644 --- a/config/initializers/repositories/repositories.rb +++ b/config/initializers/repositories/repositories.rb @@ -22,27 +22,31 @@ end Repository::Environments.create :development do |repository| repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) repository.register :institution, OrientDb::InstitutionRepository.new(OrientDb::Client.instance) + repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) + repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) repository.register :collection, OrientDb::CollectionRepository.new(OrientDb::Client.instance) + repository.register :carousel, ActiveRecord::CarouselRepository.new end Repository::Environments.create :test do |repository| + repository.register :carousel, ActiveRecord::CarouselRepository.new repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) + repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) repository.register :collection, OrientDb::CollectionRepository.new(OrientDb::Client.instance) end Repository::Environments.create :production do |repository| + repository.register :carousel, ActiveRecord::CarouselRepository.new repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) + repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) repository.register :collection, OrientDb::CollectionRepository.new(OrientDb::Client.instance) end diff --git a/config/orientdb.yml b/config/orientdb.yml index 33d7dae7cccd737915522aaa7ff9abc3ac34f4fb..07945002eacbdb755ce3058bf6ff217959fc76e8 100644 --- a/config/orientdb.yml +++ b/config/orientdb.yml @@ -1,6 +1,6 @@ development: &development host: localhost - database: portalmec + database: PortalMEC username: admin password: admin port: 2480 diff --git a/config/routes.rb b/config/routes.rb index adc99e689ca67d734145629317ec58bf6779491f..dda50d5997d878742652821529a377cb0dc83b2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + require 'sidekiq/web' + devise_for :users namespace :auth do @@ -8,24 +10,33 @@ Rails.application.routes.draw do namespace :management do root 'welcome#index' - # statistics - get 'statistics/', to: 'statistics#index', as: 'index_statistics' - get 'statistics/users/' => 'statistics#users', as: 'users_statistics' - get 'statistics/collections' => 'statistics#collections', as: 'collections_statistics' - get 'statistics/accesses' => 'statistics#accesses', as: 'accesses_statistics' - get 'statistics/downloads' => 'statistics#downloads', as: 'downloads_statistics' + resources :statistics do + collection do + get :users + get :collections + get :accesses + get :downloads + end + end resources :users resources :highlights + resources :carousels + + mount Sidekiq::Web, at: '/sidekiq' end root 'welcome#index' - resources :learning_objects - post '/learning_objects/:id/like' => 'learning_objects#like', as: 'like_learning_object' + resources :learning_objects do + member do + post :like + end + end resources :institutions resources :collections + resources :subjects, only: [:index, :show] get 'users/:id', to: 'users#show', as: 'users_show' diff --git a/db/migrate/20150922141008_create_carousels.rb b/db/migrate/20150922141008_create_carousels.rb new file mode 100644 index 0000000000000000000000000000000000000000..4e0e3bfa95e6d95a57b3691e5af9d560a6007063 --- /dev/null +++ b/db/migrate/20150922141008_create_carousels.rb @@ -0,0 +1,10 @@ +class CreateCarousels < ActiveRecord::Migration + def change + create_table :carousels do |t| + t.string :title + t.text :url + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20150922141009_add_image_column_to_carousels.rb b/db/migrate/20150922141009_add_image_column_to_carousels.rb new file mode 100644 index 0000000000000000000000000000000000000000..704b097e49bb25c7fee7edba4d2369b8b59d9fcd --- /dev/null +++ b/db/migrate/20150922141009_add_image_column_to_carousels.rb @@ -0,0 +1,9 @@ +class AddImageColumnToCarousels < ActiveRecord::Migration + def up + add_attachment :carousels, :image + end + + def down + remove_attachment :carousels, :image + end +end diff --git a/lib/dspace/client.rb b/lib/dspace/client.rb index a88bb8477206f7742e6ef4b7b675ffc8c191d031..e3dd70c904575bf94a3a9665e5051d3dc3ec4e06 100644 --- a/lib/dspace/client.rb +++ b/lib/dspace/client.rb @@ -1,2 +1,16 @@ -class OrientDb::Client +class Dspace::Client + @@client = nil + + def self.instance + if !@@client.nil? + return @@client + end + + begin + @@client = DspaceClient.new(Dspace::Config.rest_url) + rescue + raise 'Wrong orient db credentials' + end + end + end diff --git a/lib/orient_db/methods/edge_methods.rb b/lib/orient_db/methods/edge_methods.rb index 0784e472dcadd44dd8f858ef478248aed7319e7c..a1e13990a82db6473493ccbb38af84397bdb4051 100644 --- a/lib/orient_db/methods/edge_methods.rb +++ b/lib/orient_db/methods/edge_methods.rb @@ -2,6 +2,16 @@ module OrientDb module Methods module EdgeMethods + def create_edges_from_array(edge_class, id, array, unique=false) + edges = [] + array.each do |o| + unless unique && edge_exists?(edge_class, id, o.id) + edges << create_edge(edge_class, id, o.id) + end + end + edges + end + ## # Count the number of edges existent def get_in_edges_count(edge_class, id) @@ -13,6 +23,15 @@ module OrientDb connection.command "CREATE EDGE #{edge_class} FROM #{from_id} TO #{to_id}" end + def get_edges_end(edge_class, type, vertex_id) + connection.query sprintf("SELECT expand(%s('%s')) FROM %s", type, edge_class, vertex_id) + end + + def edge_exists?(edge_class, from_id, to_id) + edge = connection.query sprintf("SELECT outE('%s') FROM %s WHERE out('%s') CONTAINS %s", edge_class, from_id, edge_class, to_id) + !edge.empty? + end + end end end diff --git a/lib/orient_db/methods/generic_methods.rb b/lib/orient_db/methods/generic_methods.rb new file mode 100644 index 0000000000000000000000000000000000000000..fe39c0f59a86e6f4bd672ef4186c2dfc632feee6 --- /dev/null +++ b/lib/orient_db/methods/generic_methods.rb @@ -0,0 +1,15 @@ +module OrientDb + module Methods + module GenericMethods + + def get_by_rid(rid) + connection.get_document(rid) + end + + def select_by_property(from, prop_name, prop_value) + connection.query sprintf("SELECT FROM %s WHERE %s = '%s'", from, prop_name, prop_value) + end + + end + end +end \ No newline at end of file diff --git a/lib/search_engine/orientdb_lucene.rb b/lib/search_engine/orientdb_lucene.rb index 565a04963787ea9c8628e0aed87a490dd1256f42..672c05ee70050f873aa2742e6c7a6d0538cbe405 100644 --- a/lib/search_engine/orientdb_lucene.rb +++ b/lib/search_engine/orientdb_lucene.rb @@ -5,11 +5,5 @@ module SearchEngine learning_object_repository.search(qry) end - private - - def learning_object_repository - repository.for(:learning_object) - end - end end diff --git a/lib/tasks/dspace.rake b/lib/tasks/dspace.rake new file mode 100644 index 0000000000000000000000000000000000000000..f2c2770d952d93686f000382b9e5be6ec6100523 --- /dev/null +++ b/lib/tasks/dspace.rake @@ -0,0 +1,101 @@ +require 'dspace_rest_client' + +namespace :dspace do + desc "Dspace tasks" + + task import: :environment do + desc "Import DSpace items to LearningObject Repositoy" + + include RepositoriesProxy + + # Quantity of items fetched on each iteration + limit = 500 + + # Start point from where items will be fetched + offset = 0 + + loop do + + puts " --> importing items from #{offset} to #{offset+limit}" + + begin + # Get items from dspace (from offset to offset+limit) + dspace_items = get_items_from_dspace(limit,offset) + rescue + # Sleeps for a while to wait database's recovery + sleep(10.seconds) + # Goes to next iteration to retry + next + else + # Terminate loop if there are no more items to import + break if dspace_items.empty? + + # Increment offset, to get new items on next iteration + offset = offset + limit + + # Iterates through items + # Verifies if item is already on repository + # Initializes new LearningObjects + # and saves them on LearningObjects's repository + dspace_items.each do |item| + result = learning_object_repository.get_by_dspace_id item.id + if result.nil? + learning_object = initialize_learning_object item + learning_object_repository.save learning_object + end + end + + end + + end + + end + + private + + def dspace_repository + @dspace_repository ||= Dspace::Client.instance.repository.item_repository + end + + def get_items_from_dspace(limit, offset) + dspace_repository.get_all_items( + expand: ['metadata','bitstreams'], + limit: limit, offset: offset + ) + end + + def initialize_learning_object item + metadata = build_array_of(item.metadata) + bitstreams = build_array_of(item.bit_streams) + current_date = Time.new + + LearningObject.new( + :name => item.name, + :description => select_value_of(metadata, "dc.description"), + :thumbnail => '/thumbnails/default_thumbnail.jpg', + :created_at => current_date, + :last_modified => current_date, + :id_dspace => item.id, + :type => item.type, + :bitstreams => bitstreams, + :metadata => metadata + ) + end + + def build_array_of(item_content=[]) + return item_content if item_content.nil? + content_array = [] + item_content.each do |i| + content_array << i.to_h + end + return content_array + end + + def select_value_of(array, key) + descriptions = array.select { |a| a[:key] == key } + unless descriptions.empty? + descriptions.first[:value] + end + end + +end diff --git a/lib/tasks/fakeData.rake b/lib/tasks/fakeData.rake new file mode 100644 index 0000000000000000000000000000000000000000..07f90f587c7cc4d7c781eb0b039ca14ca40a26be --- /dev/null +++ b/lib/tasks/fakeData.rake @@ -0,0 +1,89 @@ +namespace :fakedata do + desc "Fake data generation tasks" + + task generate_users: :environment do + desc "Generate fake Users" + + include RepositoriesProxy + + total_new_users = 50 + + (1..total_new_users).each do |i| + user = User.new( + :name => "User#{i}", + :email => "user#{i}@inf.ufpr.br", + :password => "1234567890", + :password_confirmation => "1234567890" + ) + user.save + end + end + + task generate_data: :environment do + desc "Generate fake user Likes/Views data" + + include RepositoriesProxy + + # Quantity of items fetched on each iteration + limit = 100 + + # Start point from where items will be fetched + offset = 0 + + users = User.all + + loop do + + begin + # Get items from dspace (from offset to offset+limit) + learning_objects = learning_object_repository.all_from_offset_to_limit(limit,offset) + rescue + # Sleeps for a while to wait database's recovery + sleep(30.seconds) + # Goes to next iteration to retry + next + else + # Terminate loop if there are no more items to import + break if learning_objects.empty? + + # Increment offset, to get new items on next iteration + offset = offset + limit + + learning_objects.each do |lo| + + users_views = [] + users_likes = [] + + users.each do |user| + # Randomize "Views" + if random_check(30) + users_views << user. id + # Randomize "Likes" + if random_check(70) + users_likes << user.id + end + end + end + + MassiveViewsCreatorWorker.perform_async(lo.id, users_views) + MassiveLikesCreatorWorker.perform_async(lo.id, users_likes) + + end + + end + + end + + end + + private + + def random_check(threshold) + if rand(1..100) <= threshold + return true + else + return false + end + end + +end diff --git a/lib/tasks/mainPage.rake b/lib/tasks/mainPage.rake index 3f2ca563b1a1ba69ad6b3a6dfd63da927295759e..bb6e25e0c90acd0dc5a38358aeb351779d7be14d 100644 --- a/lib/tasks/mainPage.rake +++ b/lib/tasks/mainPage.rake @@ -1,18 +1,17 @@ namespace :mainPage do desc "Generate the MainPage" task :highlights => :environment do - repository = Portalmec::Application.repository + include RepositoriesProxy + # repository = Portalmec::Application.repository puts 'Generate the main page subject highlights' general_highlights = Array.new - subjects = repository.for(:subject).find_all + subjects = subject_repository.all subjects.each do |subject| # select all the learning objects about that subject - objects = repository.for(:subject).get_objects(subject['@rid']) + objects = subject.learning_objects # transform the objects to RankingItem objects = objects.collect do |object| - downloads = 0 - object = repository.for(:learning_object).find(object['@rid']) - Ranking::Item.new(object.id,object.views.first["COUNT"],downloads,object.likes.first["COUNT"]) + Ranking::Item.new(object.id,object.views,object.downloads,object.likes) end # rank them rater = Ranking::Rater.new(Ranking::Strategies::BasicRater.new(0,1,100)) @@ -21,18 +20,18 @@ namespace :mainPage do (general_highlights << objects.take(5)).flatten! # add the object to the subject highlight - puts subject['name'] - repository.for(:subject).update(subject['@rid'],'set','highlights','[]') + puts subject.name + subject_repository.update(subject.id,'set','highlights','[]') objects.each do |object| - repository.for(:subject).update(subject['@rid'],'add','highlights',object.name) + subject_repository.update(subject.id,'add','highlights',object.name) end end puts 'Generating the main page highlights' - mainPage = repository.for(:mainPage).find_all.first + mainPage = main_page_repository.all.first rid = mainPage['@rid'] - repository.for(:mainPage).update(rid,'set','highlights','[]') + main_page_repository.update(rid,'set','highlights','[]') general_highlights.each do |general_highlight| - repository.for(:mainPage).update(rid,'add','highlights',general_highlight.name) + main_page_repository.update(rid,'add','highlights',general_highlight.name) end end end diff --git a/lib/tasks/orientdb.rake b/lib/tasks/orientdb.rake index 504aa1f120363f4c7d471ca017e70808a053ad6f..55a0dd8c0fb89006e8322bc81a02881e1b757698 100644 --- a/lib/tasks/orientdb.rake +++ b/lib/tasks/orientdb.rake @@ -8,4 +8,78 @@ namespace :orientdb do migrations.run end -end \ No newline at end of file + task create_learning_object_relations: :environment do + desc "Create LearningObject relations based on its metadata" + + lo_repo = Portalmec::Application.repository.for(:learning_object) + subject_repo = Portalmec::Application.repository.for(:subject) + attr_repo = Portalmec::Application.repository.for(:attribute) + + # Quantity of LearningObjects fetched on each iteration + limit = 1000 + # Starting point from where LearningObjects will be fetched + offset = 0 + + loop do + p " --> importing LearningObjects from #{offset} to #{offset+limit}" + + begin + # Get LearningObjects from OrientDB (from offset to offset+limit) + learning_objects = lo_repo.all_from_offset_to_limit(offset,limit) + rescue + # Sleeps for a while to wait database's recovery + sleep(30.seconds) + # Goes to next iteration to retry + next + else + # Terminate loop if there are no more LearningObjects + break if learning_objects.empty? + + learning_objects.each do |lo| + metadata = get_unique_matadata_keys(lo) + subjects = metadata["dc.subject.category"] + subjects ||= [] + metadata.delete("dc.subject.category") + lo.subjects=[] + lo.attributes=[] + + subjects.each do |subject_name| + subject = subject_repo.find_by_name(subject_name) + if subject.nil? + subject = Subject.new(:name => subject_name) + subject_repo.create(subject) + end + lo.subjects << subject + end + + metadata.each do |key, value| + value.each do |v| + attribute = attr_repo.find_by_key_and_value(key,v).first + if attribute.nil? + attribute = Attribute.new(:key => key, :value => v) + attr_repo.create(attribute) + end + lo.attributes << attribute + end + end + + lo_repo.create_relations(lo) + end + + offset += limit + end + end + + end + + def get_unique_matadata_keys(lo) + hash = {} + lo.metadata.each do |m| + unless hash.has_key?(m['key']) + hash[m['key']] = lo.get_metadata_values_of(m['key']) + end + end + hash + end + +end diff --git a/lib/tasks/thumbnail.rake b/lib/tasks/thumbnail.rake new file mode 100644 index 0000000000000000000000000000000000000000..7f7a393b1117441b0ddcd5f0a419a0cf1c241295 --- /dev/null +++ b/lib/tasks/thumbnail.rake @@ -0,0 +1,39 @@ +namespace :thumbnail do + + desc "Generate Thumbnails" + task :generate => :environment do + + include RepositoriesProxy + + # Quantity of items fetched on each iteration + limit = 500 + + # Start point from where items will be fetched + offset = 0 + + loop do + + begin + # Get items from dspace (from offset to offset+limit) + items = learning_object_repository.all_from_offset_to_limit(limit,offset) + rescue + # Sleeps for a while to wait database's recovery + sleep(30.seconds) + # Goes to next iteration to retry + next + else + # Terminate loop if there are no more items to import + break if items.empty? + + # Increment offset, to get new items on next iteration + offset = offset + limit + + items.each do |item| + ThumbnailGeneratorWorker.perform_async(item.id) + end + + end + end + end + +end diff --git a/lib/thumbnail/creation.rb b/lib/thumbnail/creation.rb new file mode 100644 index 0000000000000000000000000000000000000000..0531f65155074be2661e8ce889e30e7fd48f33f3 --- /dev/null +++ b/lib/thumbnail/creation.rb @@ -0,0 +1,68 @@ +module Thumbnail + module Creation + + include Formats + + def generate_thumbnail(input, filename, size) + unless accepted_formats.include? file_format(filename) + return default_thumbnail + else + thumbnail = thumbnail_path(filename, size) + output = "#{root_dir}#{thumbnail}" + begin + if accepted_video_formats.include? File.extname(input) + generate_video_thumbnail(input, output, size) + else + generate_image_thumbnail(input, output, size) + end + rescue + return default_thumbnail + else + return thumbnail + end + end + + end + + def default_thumbnail + @default_thumbnail ||= nil + end + + private + + def generate_video_thumbnail(input,output,size) + movie = FFMPEG::Movie.new(input) + frame = (movie.duration * 25/100).floor + movie.screenshot(output, + { seek_time: frame, resolution: size }, + preserve_aspect_ratio: :width) + end + + def generate_image_thumbnail(input,output,size) + # Read the image and resize it. The `change_geometry' method + # computes the new image geometry and yields to a block. The + # return value of the block is the return value of the method. + img = Magick::Image.read(input)[0] + img.change_geometry!(size) { |cols, rows| img.thumbnail! cols, rows } + img.write(output) + end + + def encode_hash_from(object) + Digest::SHA1.hexdigest object + end + + def thumbnail_path(filename, size) + thumbnail_name = encode_hash_from filename + thumbnail_path = "#{thumbnails_dir}/#{thumbnail_name}_#{size}.jpg" + end + + def thumbnails_dir + @thumbnails_dir ||= "/thumbnails" + end + + def root_dir + @root_dir ||= Rails.root.join('public') + end + + end +end diff --git a/lib/thumbnail/formats.rb b/lib/thumbnail/formats.rb new file mode 100644 index 0000000000000000000000000000000000000000..4df246e9bc30576c0886551952073f63750650cc --- /dev/null +++ b/lib/thumbnail/formats.rb @@ -0,0 +1,36 @@ +module Thumbnail + module Formats + + def file_format file + unless file.nil? + file_format = File.extname(file) + else + file_format = "" + end + file_format + end + + def accepted_video_formats + lower = [".mp4", ".wmv", ".3gp", ".asf", ".avi", ".flv", ".mov", ".mpg", ".mpeg", ".rmvb", ".vob", ".webm"] + upper = [".MP4", ".WMV", ".3GP", ".ASF", ".AVI", ".FLV", ".MOV", ".MPG", ".MPEG", ".RMVB", ".VOB", ".WEBM"] + return lower + upper + end + + def accepted_image_formats + lower = [".jpg", ".jpeg", ".gif", ".png", ".bmp", ".tif"] + upper = [".JPG", ".JPEG", ".GIF", ".PNG", ".BMP", ".TIF"] + return lower + upper + end + + def accepted_other_formats + lower = [".pdf", ".pps"] + upper = [".PDF", ".PPS"] + return lower + upper + end + + def accepted_formats + return accepted_video_formats + accepted_image_formats + accepted_other_formats + end + + end +end diff --git a/test/controllers/management/carousel_controller_test.rb b/test/controllers/management/carousel_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..5ef47df22551ab99c7d5e8bfd325783d84fc806a --- /dev/null +++ b/test/controllers/management/carousel_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Management::CarouselControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/carousels.yml b/test/fixtures/carousels.yml new file mode 100644 index 0000000000000000000000000000000000000000..874eb455b15023db983a48bf8a96c01aaa9acde1 --- /dev/null +++ b/test/fixtures/carousels.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + url: MyText + +two: + title: MyString + url: MyText diff --git a/test/models/carousel_test.rb b/test/models/carousel_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..26c20b1e122e221fdec4d8ab8789e1a060cbeb11 --- /dev/null +++ b/test/models/carousel_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CarouselTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/learning_object_test.rb b/test/models/learning_object_test.rb index 10d349407170226579f52f7a5395e55c37b82958..3c3932c319c6291c1023d103d84bf24a0ba765e7 100644 --- a/test/models/learning_object_test.rb +++ b/test/models/learning_object_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class LearningObjectTest < ActiveSupport::TestCase should validate_presence_of(:name) - should validate_presence_of(:date_creation) + should validate_presence_of(:created_at) should validate_presence_of(:type) should validate_presence_of(:likes) should validate_presence_of(:views)