From 1a1838a36334d0b48bc50ca8cd529b7e0844446e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 11 Apr 2014 14:57:00 +0600 Subject: [PATCH] [#369] add templates; add codemirror --- Gemfile | 3 + Gemfile.lock | 7 + .../javascripts/angular-new/config.js.erb | 3 +- .../controllers/activity_controller.js | 8 + .../git_delete_branch_notification.nghaml | 16 ++ .../git_new_push_notification.nghaml | 27 ++++ .../templates/new_comment_notification.nghaml | 22 +++ .../templates/new_issue_notification.nghaml | 16 ++ .../javascripts/angularjs/locales.js.erb | 28 +++- app/assets/javascripts/new_application.js | 18 +++ .../stylesheets/new_application.css.scss | 3 +- app/controllers/home_controller.rb | 1 + app/helpers/activity_feeds_helper.rb | 26 --- app/models/concerns/feed/comment.rb | 2 +- app/views/home/activity.html.haml | 23 +-- app/views/home/activity.json.jbuilder | 46 +++++- config/application.rb | 2 + .../{codemirror.js => old-codemirror.js} | 0 .../keymaps/emacs.js | 0 .../keymaps/vim.js | 0 .../modes/clike.js | 0 .../modes/clojure.js | 0 .../modes/coffeescript.js | 0 .../modes/css.js | 0 .../modes/diff.js | 0 .../modes/gfm.js | 0 .../modes/go.js | 0 .../modes/groovy.js | 0 .../modes/haskell.js | 0 .../modes/htmlembedded.js | 0 .../modes/htmlmixed.js | 0 .../modes/javascript.js | 0 .../modes/jinja2.js | 0 .../modes/less.js | 0 .../modes/lua.js | 0 .../modes/markdown.js | 0 .../modes/mysql.js | 0 .../modes/ntriples.js | 0 .../modes/pascal.js | 0 .../modes/perl.js | 0 .../modes/php.js | 0 .../modes/plsql.js | 0 .../modes/python.js | 0 .../{codemirror => old-codemirror}/modes/r.js | 0 .../modes/rpm-changes.js | 0 .../modes/rpm-spec.js | 0 .../modes/rst.js | 0 .../modes/ruby.js | 0 .../modes/rust.js | 0 .../modes/scheme.js | 0 .../modes/shell.js | 0 .../modes/smalltalk.js | 0 .../modes/sparql.js | 0 .../modes/stex.js | 0 .../modes/tiddlywiki.js | 0 .../modes/velocity.js | 0 .../modes/verilog.js | 0 .../modes/xml.js | 0 .../modes/xmlpure.js | 0 .../modes/yaml.js | 0 .../{codemirror => old-codemirror}/overlay.js | 0 .../{codemirror => old-codemirror}/runmode.js | 0 vendor/assets/javascripts/ui-codemirror.js | 148 ++++++++++++++++++ vendor/assets/javascripts/vendor.js | 6 +- .../{codemirror.scss => old-codemirror.scss} | 0 .../modes/diff.scss | 0 .../modes/rpm-spec.scss | 0 .../modes/tiddlywiki.scss | 0 .../themes/cobalt.scss | 0 .../themes/eclipse.scss | 0 .../themes/elegant.scss | 0 .../themes/monokai.scss | 0 .../themes/neat.scss | 0 .../themes/night.scss | 0 .../themes/rubyblue.scss | 0 vendor/assets/stylesheets/vendor.scss | 10 +- 76 files changed, 347 insertions(+), 68 deletions(-) create mode 100644 app/assets/javascripts/angular-new/templates/git_delete_branch_notification.nghaml create mode 100644 app/assets/javascripts/angular-new/templates/git_new_push_notification.nghaml create mode 100644 app/assets/javascripts/angular-new/templates/new_comment_notification.nghaml create mode 100644 app/assets/javascripts/angular-new/templates/new_issue_notification.nghaml rename vendor/assets/javascripts/{codemirror.js => old-codemirror.js} (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/keymaps/emacs.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/keymaps/vim.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/clike.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/clojure.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/coffeescript.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/css.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/diff.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/gfm.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/go.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/groovy.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/haskell.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/htmlembedded.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/htmlmixed.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/javascript.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/jinja2.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/less.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/lua.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/markdown.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/mysql.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/ntriples.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/pascal.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/perl.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/php.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/plsql.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/python.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/r.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/rpm-changes.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/rpm-spec.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/rst.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/ruby.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/rust.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/scheme.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/shell.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/smalltalk.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/sparql.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/stex.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/tiddlywiki.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/velocity.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/verilog.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/xml.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/xmlpure.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/modes/yaml.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/overlay.js (100%) rename vendor/assets/javascripts/{codemirror => old-codemirror}/runmode.js (100%) create mode 100644 vendor/assets/javascripts/ui-codemirror.js rename vendor/assets/stylesheets/{codemirror.scss => old-codemirror.scss} (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/modes/diff.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/modes/rpm-spec.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/modes/tiddlywiki.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/cobalt.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/eclipse.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/elegant.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/monokai.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/neat.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/night.scss (100%) rename vendor/assets/stylesheets/{codemirror => old-codemirror}/themes/rubyblue.scss (100%) diff --git a/Gemfile b/Gemfile index aff711ecc..c14189932 100644 --- a/Gemfile +++ b/Gemfile @@ -75,6 +75,7 @@ gem 'angular-i18n', '0.1.2' gem 'js-routes' gem 'soundmanager-rails' gem 'angular-ui-bootstrap-rails' +gem 'angular-rails-templates' gem 'time_diff' @@ -88,6 +89,8 @@ gem 'therubyrhino', '~> 1.73.1', platforms: :jruby gem 'bootstrap-sass', '~> 3.1.1' gem 'font-awesome-rails' +gem 'codemirror-rails' + group :production do gem "airbrake", '~> 3.1.2' gem 'bluepill', '~> 0.0.60', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4443218c4..c9e34c7f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,9 @@ GEM ancestry (2.0.0) activerecord (>= 3.0.0) angular-i18n (0.1.2) + angular-rails-templates (0.0.7) + railties (>= 3.1) + sprockets angular-ui-bootstrap-rails (0.10.0) angularjs-rails (1.2.15) arel (4.0.2) @@ -102,6 +105,8 @@ GEM activesupport (>= 3.0) cocaine (0.5.3) climate_control (>= 0.0.3, < 1.0) + codemirror-rails (3.22) + railties (>= 3.0, < 5) coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -468,6 +473,7 @@ DEPENDENCIES airbrake (~> 3.1.2) ancestry (~> 2.0.0) angular-i18n (= 0.1.2) + angular-rails-templates angular-ui-bootstrap-rails angularjs-rails (~> 1.2.15) attr_encrypted (~> 1.3.2) @@ -480,6 +486,7 @@ DEPENDENCIES capistrano capistrano_colors charlock_holmes (~> 0.6.9) + codemirror-rails coffee-rails (~> 4.0.1) compass-rails (~> 1.1.6) creole diff --git a/app/assets/javascripts/angular-new/config.js.erb b/app/assets/javascripts/angular-new/config.js.erb index 428f238a3..bccb52419 100644 --- a/app/assets/javascripts/angular-new/config.js.erb +++ b/app/assets/javascripts/angular-new/config.js.erb @@ -1,6 +1,7 @@ //var RosaABF = angular.module('RosaABF', ['ngResource', 'ng-rails-csrf', 'angular-i18n', 'angularMoment']); var RosaABF = angular.module('RosaABF', ['ui.bootstrap', 'angular-i18n', 'angularMoment', - 'chieffancypants.loadingBar', 'ngSanitize']); + 'chieffancypants.loadingBar', 'ngSanitize', 'templates', + 'ui.codemirror']); var LocalesHelper = function($locale) { var locales = { diff --git a/app/assets/javascripts/angular-new/controllers/activity_controller.js b/app/assets/javascripts/angular-new/controllers/activity_controller.js index 3dc457d5a..b8c587f53 100644 --- a/app/assets/javascripts/angular-new/controllers/activity_controller.js +++ b/app/assets/javascripts/angular-new/controllers/activity_controller.js @@ -55,4 +55,12 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte return content.kind === 'new_comment_notification' || content.kind === 'new_comment_commit_notification'; }; + + $scope.getTemplate = function(content) { + if(content.kind == 'new_commit_notification' || content.kind == 'git_new_push_notification' || + content.kind == 'git_delete_branch_notification' || content.kind == 'new_issue_notification') { + return content.kind + '.html';} + else return 'new_comment_notification.html'; + }; + }]); diff --git a/app/assets/javascripts/angular-new/templates/git_delete_branch_notification.nghaml b/app/assets/javascripts/angular-new/templates/git_delete_branch_notification.nghaml new file mode 100644 index 000000000..7ce440a23 --- /dev/null +++ b/app/assets/javascripts/angular-new/templates/git_delete_branch_notification.nghaml @@ -0,0 +1,16 @@ +%i.img-circle.btn-danger.fa.fa-times +.timeline-item{ 'ng-cloak' => true } + %h3.timeline-header + %a{ 'ng-href' => "{{item.user.link}}" } + %img{ 'ng-src' => "{{item.user.image}}" } + {{item.user.uname}} + %span.time{ popover: "{{item.date | amDateFormat:'ddd, LLL'}}", + "popover-trigger" => "mouseenter", 'popover-append-to-body' => 'true' } + %span.glyphicon.glyphicon-time + %span {{item.date | amDateFormat:'HH:mm'}} + .clearfix + .timeline-body + %p + {{'notification.push.delete_branch' | i18n}} + {{ item.branch_name + ('notification.in_project' | i18n)}} + %a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}} diff --git a/app/assets/javascripts/angular-new/templates/git_new_push_notification.nghaml b/app/assets/javascripts/angular-new/templates/git_new_push_notification.nghaml new file mode 100644 index 000000000..65038df5a --- /dev/null +++ b/app/assets/javascripts/angular-new/templates/git_new_push_notification.nghaml @@ -0,0 +1,27 @@ +%i.img-circle.bg-primary.fa.fa-sign-in +.timeline-item{ 'ng-cloak' => true } + %h3.timeline-header + %a{ 'ng-href' => "{{item.user.link}}" } + %img{ 'ng-src' => "{{item.user.image}}" } + {{item.user.uname}} + %span.time{ popover: "{{item.date | amDateFormat:'ddd, LLL'}}", + "popover-trigger" => "mouseenter", 'popover-append-to-body' => 'true' } + %span.glyphicon.glyphicon-time + %span {{item.date | amDateFormat:'HH:mm'}} + .clearfix + .timeline-body + %p + {{'notification.push.' + item.change_type + '_branch' | i18n}} + {{ item.branch_name + ('notification.in_project' | i18n)}} + %a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}} + + .timeline-footer + .row + .container-fluid{ 'ng-repeat' => 'commit in item.last_commits' } + .col-sm-3.col-md-2 + %a{ 'ng-href' => "{{commit.commit_path}}" } {{commit.hash}} + .col-sm-8.col-md-9{ 'ng-bind-html' => "commit.message" } + .clearfix + + %br{ 'ng-if' => "item.other_commits" } + %a{ 'ng-if' => "item.other_commits", 'ng-href' => "{{item.other_commits_path}}" } {{item.other_commits}} diff --git a/app/assets/javascripts/angular-new/templates/new_comment_notification.nghaml b/app/assets/javascripts/angular-new/templates/new_comment_notification.nghaml new file mode 100644 index 000000000..7b3091857 --- /dev/null +++ b/app/assets/javascripts/angular-new/templates/new_comment_notification.nghaml @@ -0,0 +1,22 @@ +%i.img-circle.btn-warning.fa.fa-comment +.timeline-item{ 'ng-cloak' => true } + %h3.timeline-header + %a{ 'ng-href' => "{{item.user.link}}" } + %img{ 'ng-src' => "{{item.user.image}}" } + {{item.user.uname}} + %span.time{ popover: "{{item.date | amDateFormat:'ddd, LLL'}}", + "popover-trigger" => "mouseenter", 'popover-append-to-body' => 'true' } + %span.glyphicon.glyphicon-time + %span {{item.date | amDateFormat:'HH:mm'}} + .clearfix + .timeline-body + %p + {{'notification.new_comment.title' | i18n}} + %a{ 'ng-href' => "{{item.issue.link}}" } {{item.issue.title}} + + %blockquote{ 'ng-bind-html' => "item.body" } + + .timeline-footer + %a.btn.btn-primary.btn-xs{ 'ng-href' => "{{item.issue.link + '#comment' + item.issue.read_more}}" } + {{'read_more' | i18n}} + {{item.kind}} diff --git a/app/assets/javascripts/angular-new/templates/new_issue_notification.nghaml b/app/assets/javascripts/angular-new/templates/new_issue_notification.nghaml new file mode 100644 index 000000000..6154e78c8 --- /dev/null +++ b/app/assets/javascripts/angular-new/templates/new_issue_notification.nghaml @@ -0,0 +1,16 @@ +%i.img-circle.btn-success.fa.fa-check +.timeline-item{ 'ng-cloak' => true } + %h3.timeline-header + %a{ 'ng-href' => "{{item.user.link}}" } + %img{ 'ng-src' => "{{item.user.image}}" } + {{item.user.uname}} + %span.time{ popover: "{{item.date | amDateFormat:'ddd, LLL'}}", + "popover-trigger" => "mouseenter", 'popover-append-to-body' => 'true' } + %span.glyphicon.glyphicon-time + %span {{item.date | amDateFormat:'HH:mm'}} + .clearfix + .timeline-body + %p + {{('notification.new_issue' | i18n) + ('notification.in_project' | i18n)}} + %a{ 'ng-href' => "{{item.project_link}}" } {{item.project_name_with_owner}} + %a{ 'ng-href' => "{{item.issue.link}}" } {{item.issue.title}} \ No newline at end of file diff --git a/app/assets/javascripts/angularjs/locales.js.erb b/app/assets/javascripts/angularjs/locales.js.erb index 2a43bb873..83ef318d9 100644 --- a/app/assets/javascripts/angularjs/locales.js.erb +++ b/app/assets/javascripts/angularjs/locales.js.erb @@ -17,7 +17,19 @@ var _locales = { 'autostart_statuses.1': 'Раз в день', 'autostart_statuses.2': 'Раз в неделю', <%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>, - <%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %> + + // + <%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %>, + + 'notification.new_comment.title': 'добавил новый комментарий к задаче ', + 'notification.push.delete_branch': 'удалил ветку ', + 'notification.push.create_branch': 'создал новую ветку ', + 'notification.push.update_branch': 'внес изменения в ветку ', + 'notification.in_project': ' в проекте ', + 'notification.new_issue': 'добавил новую задачу', + + 'read_more': 'Читать дальше', + }, <%I18n.locale = :en%> 'en-us': { @@ -35,6 +47,18 @@ var _locales = { 'autostart_statuses.1': 'Once a day', 'autostart_statuses.2': 'Once a week', <%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>, - <%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %> + + // + <%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %>, + + 'notification.new_comment.title': 'added a new comment in issue ', + 'notification.push.delete_branch': 'deleted a branch ', + 'notification.push.create_branch': 'created a new branch ', + 'notification.push.update_branch': 'pushed to branch ', + 'notification.in_project': ' in project ', + 'notification.new_issue': 'added a new issue ', + + 'read_more': 'Read more', + } }; \ No newline at end of file diff --git a/app/assets/javascripts/new_application.js b/app/assets/javascripts/new_application.js index 600bf831e..490e6317a 100644 --- a/app/assets/javascripts/new_application.js +++ b/app/assets/javascripts/new_application.js @@ -1,4 +1,5 @@ //= require jquery +//= require jquery_ujs //= require js-routes // Loads all Bootstrap javascripts @@ -8,6 +9,7 @@ //= require angular //= require angular-sanitize //= require angular-ui-bootstrap-tpls +//= require ui-codemirror //= require angular-i18n //= require angularjs/locales @@ -16,3 +18,19 @@ //= require_tree ./angular-new //= require loading-bar + +//= require codemirror +// ### TODO require all files in codemirror/modes ### +//= require codemirror/modes/ruby +//= require codemirror/modes/javascript +//= require codemirror/modes/markdown + +$(document).ready(function() { + window.CodeMirrorRun = function(code) { + //CodeMirror.runMode(code.innerHTML.replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>'), code.className, code); + CodeMirror.runMode(code.innerHTML, 'markdown', code); + } + + $('.md_and_cm').each(function (code) { CodeMirrorRun(this); }); + +}); diff --git a/app/assets/stylesheets/new_application.css.scss b/app/assets/stylesheets/new_application.css.scss index 53e055669..bf1163bfe 100644 --- a/app/assets/stylesheets/new_application.css.scss +++ b/app/assets/stylesheets/new_application.css.scss @@ -9,4 +9,5 @@ $navbar-default-link-hover-color: #CEE7FF; @import "custom_bootstrap"; @import "timeline"; @import "font-awesome"; -@import "loading-bar"; \ No newline at end of file +@import "loading-bar"; +@import "codemirror"; diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 4c07325ba..3feb6d763 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -11,6 +11,7 @@ class HomeController < ApplicationController @activity_feeds = current_user.activity_feeds @activity_feeds = @activity_feeds.where(kind: "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all @activity_feeds = @activity_feeds.paginate page: params[:page] + respond_to do |format| format.html { request.xhr? ? render('_list', layout: false) : render('activity') } format.json {} diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb index 95b8f1643..ffaf6166f 100644 --- a/app/helpers/activity_feeds_helper.rb +++ b/app/helpers/activity_feeds_helper.rb @@ -18,30 +18,4 @@ module ActivityFeedsHelper def user_link(user, user_name, full_url = false) user.persisted? ? link_to(user_name, full_url ? user_url(user) : user_path(user)) : user_name end - - def get_title_from_activity_item(item, opts = {}) - case item.kind - when 'new_comment_notification' - res = t('notifications.bodies.new_comment_notification.title', { user_link: nil }) - res << ' ' << t('notifications.bodies.new_comment_notification.content', - { issue_link: link_to(item.data[:issue_title], opts[:path]) }) - when 'git_new_push_notification' - res = t("notifications.bodies.#{item.data[:change_type]}_branch", - { branch_name: item.data[:branch_name], user_link: nil }) - res << ' ' << t('notifications.bodies.project', project_link: link_to(opts[:project_name_with_owner], opts[:path])) - else nil - end - raw res - end - - def get_path_from_activity_item(item, opts = {}) - case item.kind - when 'new_comment_notification' - project_issue_path(opts[:project_name_with_owner], item.data[:issue_serial_id]) - when 'git_new_push_notification' - project_path(opts[:project_name_with_owner]) - else - '?' - end - end end diff --git a/app/models/concerns/feed/comment.rb b/app/models/concerns/feed/comment.rb index 76a7e8e50..1c62007dc 100644 --- a/app/models/concerns/feed/comment.rb +++ b/app/models/concerns/feed/comment.rb @@ -23,7 +23,7 @@ module Feed::Comment user_name: user.name, user_email: user.email, user_id: user_id, - comment_body: truncate(body, length: 1000, omission: '…'), + comment_body: truncate(body, length: 100, omission: '…'), issue_title: commentable.title, issue_serial_id: commentable.serial_id, project_id: commentable.project.id, diff --git a/app/views/home/activity.html.haml b/app/views/home/activity.html.haml index 45d1425be..b89e1f62e 100644 --- a/app/views/home/activity.html.haml +++ b/app/views/home/activity.html.haml @@ -43,28 +43,7 @@ %span{ 'ng-show' => "needShowTimeLabel($index)", 'ng-cloak' => true } {{item.date | amDateFormat:'ll'}} / timeline item - %li - %i.img-circle.fa{ 'ng-class' => "getTimeLinefaClass(item)" } - .timeline-item - %h3.timeline-header - %a{ 'ng-href' => "{{item.user.link}}" } - %img{ 'ng-src' => "{{item.user.image}}" } - {{item.user.uname}} - %span.time{ 'ng-cloak' => true, popover: "{{item.date | amDateFormat:'ddd, LLL'}}", - "popover-trigger" => "mouseenter", 'popover-append-to-body' => 'true' } - %span.glyphicon.glyphicon-time - %span {{item.date | amDateFormat:'HH:mm'}} - .clearfix - .timeline-body - -#%p{ 'ng-bind-html' => "item.title" } - %p{ 'ng-bind-html' => "item.title" } - %blockquote{ 'ng-if' => "isComment(item)" } - {{item.body}} - %p{ 'ng-if' => "!isComment(item)", 'ng-bind-html' => "item.body" } - - .timeline-footer - %a.btn.btn-primary.btn-xs{ 'ng-href' => "{{item.read_more}}", 'ng-if' => "isComment(item)" } - = t('layout.read_more') + %li{ 'ng-include' => "getTemplate(item)" } .hide{ 'ng-repeat-end' => true } %li %i.img-circle.bg-primary.fa.fa-clock-o diff --git a/app/views/home/activity.json.jbuilder b/app/views/home/activity.json.jbuilder index 977d363d8..cda3d25bb 100644 --- a/app/views/home/activity.json.jbuilder +++ b/app/views/home/activity.json.jbuilder @@ -1,5 +1,5 @@ json.array!(@activity_feeds) do |item| - json.cache! item do + #json.cache! item, expires_in: 10.minutes do json.date item.created_at json.kind item.kind user = get_user_from_activity_item(item) @@ -8,18 +8,50 @@ json.array!(@activity_feeds) do |item| json.image avatar_url(user, :small) if user.persisted? json.uname (user.fullname || user.email) end if user + project_name_with_owner = "#{item.data[:project_owner]}/#{item.data[:project_name]}" + @project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name]) + json.project_name_with_owner project_name_with_owner - path = get_path_from_activity_item(item, project_name_with_owner: project_name_with_owner) - json.title get_title_from_activity_item(item, user: user, project_name_with_owner: project_name_with_owner, path: path) case item.kind when 'new_comment_notification' - json.read_more path + "#comment#{item.data[:comment_id]}" - json.body short_message(item.data[:comment_body], 1000) + json.issue do + json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present? + json.title short_message(item.data[:issue_title], 50) + json.read_more item.data[:comment_id] + end + json.body markdown(short_message(item.data[:comment_body], 100)) + when 'git_new_push_notification' - json.body render('commits_list', item: item, project_name_with_owner: project_name_with_owner).html_safe + json.change_type item.data[:change_type] + json.project_link project_path(project_name_with_owner) + json.branch_name item.data[:branch_name] + + json.last_commits do + json.array! item.data[:last_commits] do |commit| + json.hash shortest_hash_id(commit[0]) + json.message markdown(short_message(commit[1], 70)) + json.commit_path commit_path(project_name_with_owner, commit[0]) + end + end + if item.data[:other_commits].present? + json.other_commits t('notifications.bodies.more_commits', count: item.data[:other_commits_count], commits: commits_pluralize(item.data[:other_commits_count])) + json.other_commits_path diff_path(project_name_with_owner, diff: item.data[:other_commits]) + end + + when 'git_delete_branch_notification' + json.branch_name item.data[:branch_name] + json.project_link project_path(project_name_with_owner) + + when 'new_issue_notification' + json.project_link project_path(project_name_with_owner) + json.issue do + json.title item.data[:issue_title] + json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present? + end + end json.id item.id - end + #end end \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 08dfc07f9..79c1da190 100644 --- a/config/application.rb +++ b/config/application.rb @@ -56,5 +56,7 @@ module Rosa config.assets.version = '1.0' config.log_redis = false + + config.angular_templates.ignore_prefix = 'angular-new/templates/' end end diff --git a/vendor/assets/javascripts/codemirror.js b/vendor/assets/javascripts/old-codemirror.js similarity index 100% rename from vendor/assets/javascripts/codemirror.js rename to vendor/assets/javascripts/old-codemirror.js diff --git a/vendor/assets/javascripts/codemirror/keymaps/emacs.js b/vendor/assets/javascripts/old-codemirror/keymaps/emacs.js similarity index 100% rename from vendor/assets/javascripts/codemirror/keymaps/emacs.js rename to vendor/assets/javascripts/old-codemirror/keymaps/emacs.js diff --git a/vendor/assets/javascripts/codemirror/keymaps/vim.js b/vendor/assets/javascripts/old-codemirror/keymaps/vim.js similarity index 100% rename from vendor/assets/javascripts/codemirror/keymaps/vim.js rename to vendor/assets/javascripts/old-codemirror/keymaps/vim.js diff --git a/vendor/assets/javascripts/codemirror/modes/clike.js b/vendor/assets/javascripts/old-codemirror/modes/clike.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/clike.js rename to vendor/assets/javascripts/old-codemirror/modes/clike.js diff --git a/vendor/assets/javascripts/codemirror/modes/clojure.js b/vendor/assets/javascripts/old-codemirror/modes/clojure.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/clojure.js rename to vendor/assets/javascripts/old-codemirror/modes/clojure.js diff --git a/vendor/assets/javascripts/codemirror/modes/coffeescript.js b/vendor/assets/javascripts/old-codemirror/modes/coffeescript.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/coffeescript.js rename to vendor/assets/javascripts/old-codemirror/modes/coffeescript.js diff --git a/vendor/assets/javascripts/codemirror/modes/css.js b/vendor/assets/javascripts/old-codemirror/modes/css.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/css.js rename to vendor/assets/javascripts/old-codemirror/modes/css.js diff --git a/vendor/assets/javascripts/codemirror/modes/diff.js b/vendor/assets/javascripts/old-codemirror/modes/diff.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/diff.js rename to vendor/assets/javascripts/old-codemirror/modes/diff.js diff --git a/vendor/assets/javascripts/codemirror/modes/gfm.js b/vendor/assets/javascripts/old-codemirror/modes/gfm.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/gfm.js rename to vendor/assets/javascripts/old-codemirror/modes/gfm.js diff --git a/vendor/assets/javascripts/codemirror/modes/go.js b/vendor/assets/javascripts/old-codemirror/modes/go.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/go.js rename to vendor/assets/javascripts/old-codemirror/modes/go.js diff --git a/vendor/assets/javascripts/codemirror/modes/groovy.js b/vendor/assets/javascripts/old-codemirror/modes/groovy.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/groovy.js rename to vendor/assets/javascripts/old-codemirror/modes/groovy.js diff --git a/vendor/assets/javascripts/codemirror/modes/haskell.js b/vendor/assets/javascripts/old-codemirror/modes/haskell.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/haskell.js rename to vendor/assets/javascripts/old-codemirror/modes/haskell.js diff --git a/vendor/assets/javascripts/codemirror/modes/htmlembedded.js b/vendor/assets/javascripts/old-codemirror/modes/htmlembedded.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/htmlembedded.js rename to vendor/assets/javascripts/old-codemirror/modes/htmlembedded.js diff --git a/vendor/assets/javascripts/codemirror/modes/htmlmixed.js b/vendor/assets/javascripts/old-codemirror/modes/htmlmixed.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/htmlmixed.js rename to vendor/assets/javascripts/old-codemirror/modes/htmlmixed.js diff --git a/vendor/assets/javascripts/codemirror/modes/javascript.js b/vendor/assets/javascripts/old-codemirror/modes/javascript.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/javascript.js rename to vendor/assets/javascripts/old-codemirror/modes/javascript.js diff --git a/vendor/assets/javascripts/codemirror/modes/jinja2.js b/vendor/assets/javascripts/old-codemirror/modes/jinja2.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/jinja2.js rename to vendor/assets/javascripts/old-codemirror/modes/jinja2.js diff --git a/vendor/assets/javascripts/codemirror/modes/less.js b/vendor/assets/javascripts/old-codemirror/modes/less.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/less.js rename to vendor/assets/javascripts/old-codemirror/modes/less.js diff --git a/vendor/assets/javascripts/codemirror/modes/lua.js b/vendor/assets/javascripts/old-codemirror/modes/lua.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/lua.js rename to vendor/assets/javascripts/old-codemirror/modes/lua.js diff --git a/vendor/assets/javascripts/codemirror/modes/markdown.js b/vendor/assets/javascripts/old-codemirror/modes/markdown.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/markdown.js rename to vendor/assets/javascripts/old-codemirror/modes/markdown.js diff --git a/vendor/assets/javascripts/codemirror/modes/mysql.js b/vendor/assets/javascripts/old-codemirror/modes/mysql.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/mysql.js rename to vendor/assets/javascripts/old-codemirror/modes/mysql.js diff --git a/vendor/assets/javascripts/codemirror/modes/ntriples.js b/vendor/assets/javascripts/old-codemirror/modes/ntriples.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/ntriples.js rename to vendor/assets/javascripts/old-codemirror/modes/ntriples.js diff --git a/vendor/assets/javascripts/codemirror/modes/pascal.js b/vendor/assets/javascripts/old-codemirror/modes/pascal.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/pascal.js rename to vendor/assets/javascripts/old-codemirror/modes/pascal.js diff --git a/vendor/assets/javascripts/codemirror/modes/perl.js b/vendor/assets/javascripts/old-codemirror/modes/perl.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/perl.js rename to vendor/assets/javascripts/old-codemirror/modes/perl.js diff --git a/vendor/assets/javascripts/codemirror/modes/php.js b/vendor/assets/javascripts/old-codemirror/modes/php.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/php.js rename to vendor/assets/javascripts/old-codemirror/modes/php.js diff --git a/vendor/assets/javascripts/codemirror/modes/plsql.js b/vendor/assets/javascripts/old-codemirror/modes/plsql.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/plsql.js rename to vendor/assets/javascripts/old-codemirror/modes/plsql.js diff --git a/vendor/assets/javascripts/codemirror/modes/python.js b/vendor/assets/javascripts/old-codemirror/modes/python.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/python.js rename to vendor/assets/javascripts/old-codemirror/modes/python.js diff --git a/vendor/assets/javascripts/codemirror/modes/r.js b/vendor/assets/javascripts/old-codemirror/modes/r.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/r.js rename to vendor/assets/javascripts/old-codemirror/modes/r.js diff --git a/vendor/assets/javascripts/codemirror/modes/rpm-changes.js b/vendor/assets/javascripts/old-codemirror/modes/rpm-changes.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/rpm-changes.js rename to vendor/assets/javascripts/old-codemirror/modes/rpm-changes.js diff --git a/vendor/assets/javascripts/codemirror/modes/rpm-spec.js b/vendor/assets/javascripts/old-codemirror/modes/rpm-spec.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/rpm-spec.js rename to vendor/assets/javascripts/old-codemirror/modes/rpm-spec.js diff --git a/vendor/assets/javascripts/codemirror/modes/rst.js b/vendor/assets/javascripts/old-codemirror/modes/rst.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/rst.js rename to vendor/assets/javascripts/old-codemirror/modes/rst.js diff --git a/vendor/assets/javascripts/codemirror/modes/ruby.js b/vendor/assets/javascripts/old-codemirror/modes/ruby.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/ruby.js rename to vendor/assets/javascripts/old-codemirror/modes/ruby.js diff --git a/vendor/assets/javascripts/codemirror/modes/rust.js b/vendor/assets/javascripts/old-codemirror/modes/rust.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/rust.js rename to vendor/assets/javascripts/old-codemirror/modes/rust.js diff --git a/vendor/assets/javascripts/codemirror/modes/scheme.js b/vendor/assets/javascripts/old-codemirror/modes/scheme.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/scheme.js rename to vendor/assets/javascripts/old-codemirror/modes/scheme.js diff --git a/vendor/assets/javascripts/codemirror/modes/shell.js b/vendor/assets/javascripts/old-codemirror/modes/shell.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/shell.js rename to vendor/assets/javascripts/old-codemirror/modes/shell.js diff --git a/vendor/assets/javascripts/codemirror/modes/smalltalk.js b/vendor/assets/javascripts/old-codemirror/modes/smalltalk.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/smalltalk.js rename to vendor/assets/javascripts/old-codemirror/modes/smalltalk.js diff --git a/vendor/assets/javascripts/codemirror/modes/sparql.js b/vendor/assets/javascripts/old-codemirror/modes/sparql.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/sparql.js rename to vendor/assets/javascripts/old-codemirror/modes/sparql.js diff --git a/vendor/assets/javascripts/codemirror/modes/stex.js b/vendor/assets/javascripts/old-codemirror/modes/stex.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/stex.js rename to vendor/assets/javascripts/old-codemirror/modes/stex.js diff --git a/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js b/vendor/assets/javascripts/old-codemirror/modes/tiddlywiki.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/tiddlywiki.js rename to vendor/assets/javascripts/old-codemirror/modes/tiddlywiki.js diff --git a/vendor/assets/javascripts/codemirror/modes/velocity.js b/vendor/assets/javascripts/old-codemirror/modes/velocity.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/velocity.js rename to vendor/assets/javascripts/old-codemirror/modes/velocity.js diff --git a/vendor/assets/javascripts/codemirror/modes/verilog.js b/vendor/assets/javascripts/old-codemirror/modes/verilog.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/verilog.js rename to vendor/assets/javascripts/old-codemirror/modes/verilog.js diff --git a/vendor/assets/javascripts/codemirror/modes/xml.js b/vendor/assets/javascripts/old-codemirror/modes/xml.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/xml.js rename to vendor/assets/javascripts/old-codemirror/modes/xml.js diff --git a/vendor/assets/javascripts/codemirror/modes/xmlpure.js b/vendor/assets/javascripts/old-codemirror/modes/xmlpure.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/xmlpure.js rename to vendor/assets/javascripts/old-codemirror/modes/xmlpure.js diff --git a/vendor/assets/javascripts/codemirror/modes/yaml.js b/vendor/assets/javascripts/old-codemirror/modes/yaml.js similarity index 100% rename from vendor/assets/javascripts/codemirror/modes/yaml.js rename to vendor/assets/javascripts/old-codemirror/modes/yaml.js diff --git a/vendor/assets/javascripts/codemirror/overlay.js b/vendor/assets/javascripts/old-codemirror/overlay.js similarity index 100% rename from vendor/assets/javascripts/codemirror/overlay.js rename to vendor/assets/javascripts/old-codemirror/overlay.js diff --git a/vendor/assets/javascripts/codemirror/runmode.js b/vendor/assets/javascripts/old-codemirror/runmode.js similarity index 100% rename from vendor/assets/javascripts/codemirror/runmode.js rename to vendor/assets/javascripts/old-codemirror/runmode.js diff --git a/vendor/assets/javascripts/ui-codemirror.js b/vendor/assets/javascripts/ui-codemirror.js new file mode 100644 index 000000000..48a5abef6 --- /dev/null +++ b/vendor/assets/javascripts/ui-codemirror.js @@ -0,0 +1,148 @@ +/* + * UI.Codemirror directive + * https://github.com/angular-ui/ui-codemirror + * + * This directive allows you to add CodeMirror to your textarea elements. + * + * The MIT License + * + * Copyright (c) 2012 the AngularUI Team, http://angular-ui.github.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +'use strict'; + +/** + * Binds a CodeMirror widget to a