From 5f900772c2a5a1bc86d4e60e1d6b6128b609b96e Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 3 Nov 2011 10:36:02 -0400 Subject: [PATCH 01/24] new favicon --- app/views/layouts/admin.html.haml | 1 - app/views/layouts/application.html.haml | 1 - app/views/layouts/devise.html.haml | 1 - app/views/layouts/profile.html.haml | 1 - app/views/layouts/project.html.haml | 1 - 5 files changed, 5 deletions(-) diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index d3de20da..8df7881c 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -6,7 +6,6 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags - %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8cc63253..eedbf116 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -10,7 +10,6 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags - %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 968fe58d..32964663 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -6,7 +6,6 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags - %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 007e03cf..a33d9d5d 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -6,7 +6,6 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags - %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index b4b51631..f8d8221a 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -6,7 +6,6 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags - %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; From 3ba392b3cb82a655a814e34759e678cdef94fdfa Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 3 Nov 2011 12:28:33 -0400 Subject: [PATCH 02/24] new ref switch --- app/assets/images/chosen-sprite.png | Bin 0 -> 396 bytes app/assets/javascripts/chosen.jquery.js | 901 ++++++++++++++++++++++ app/assets/stylesheets/chosen.css | 367 +++++++++ app/assets/stylesheets/projects.css.scss | 13 + app/controllers/application_controller.rb | 20 +- app/helpers/application_helper.rb | 9 + app/views/commits/index.html.haml | 25 +- app/views/projects/_refs.html.haml | 8 + app/views/projects/_tree.html.haml | 21 +- 9 files changed, 1314 insertions(+), 50 deletions(-) create mode 100644 app/assets/images/chosen-sprite.png create mode 100644 app/assets/javascripts/chosen.jquery.js create mode 100644 app/assets/stylesheets/chosen.css create mode 100644 app/views/projects/_refs.html.haml diff --git a/app/assets/images/chosen-sprite.png b/app/assets/images/chosen-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..d08e4b7e624c44f4fb862f23f046262780847490 GIT binary patch literal 396 zcmV;70dxL|P)~c7VWO z{Q}IDn{i!TF4#od;X3Q_#kIK3wRl==hwEDRz~*jyTo-K>u-u(nATT<+akgC{FyDRG qFW$B*q*ia+6;i9W9%5_PVDkwXFTX6NOX?H=0000' + option.html + ''; + } else { + return ""; + } + }; + AbstractChosen.prototype.results_update_field = function() { + this.result_clear_highlight(); + this.result_single_selected = null; + return this.results_build(); + }; + AbstractChosen.prototype.results_toggle = function() { + if (this.results_showing) { + return this.results_hide(); + } else { + return this.results_show(); + } + }; + AbstractChosen.prototype.results_search = function(evt) { + if (this.results_showing) { + return this.winnow_results(); + } else { + return this.results_show(); + } + }; + AbstractChosen.prototype.keyup_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + switch (stroke) { + case 8: + if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { + return this.keydown_backstroke(); + } else if (!this.pending_backstroke) { + this.result_clear_highlight(); + return this.results_search(); + } + break; + case 13: + evt.preventDefault(); + if (this.results_showing) { + return this.result_select(evt); + } + break; + case 27: + if (this.results_showing) { + return this.results_hide(); + } + break; + case 9: + case 38: + case 40: + case 16: + case 91: + case 17: + break; + default: + return this.results_search(); + } + }; + AbstractChosen.prototype.generate_field_id = function() { + var new_id; + new_id = this.generate_random_id(); + this.form_field.id = new_id; + return new_id; + }; + AbstractChosen.prototype.generate_random_char = function() { + var chars, newchar, rand; + chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"; + rand = Math.floor(Math.random() * chars.length); + return newchar = chars.substring(rand, rand + 1); + }; + return AbstractChosen; + })(); + root.AbstractChosen = AbstractChosen; +}).call(this); +(function() { + /* + Chosen source: generate output using 'cake build' + Copyright (c) 2011 by Harvest + */ + var $, Chosen, get_side_border_padding, root; + var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { + for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor; + child.__super__ = parent.prototype; + return child; + }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + root = this; + $ = jQuery; + $.fn.extend({ + chosen: function(options) { + if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) { + return this; + } + return $(this).each(function(input_field) { + if (!($(this)).hasClass("chzn-done")) { + return new Chosen(this, options); + } + }); + } + }); + Chosen = (function() { + __extends(Chosen, AbstractChosen); + function Chosen() { + Chosen.__super__.constructor.apply(this, arguments); + } + Chosen.prototype.setup = function() { + this.form_field_jq = $(this.form_field); + return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl"); + }; + Chosen.prototype.finish_setup = function() { + return this.form_field_jq.addClass("chzn-done"); + }; + Chosen.prototype.set_up_html = function() { + var container_div, dd_top, dd_width, sf_width; + this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id(); + this.container_id += "_chzn"; + this.f_width = this.form_field_jq.outerWidth(); + this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default; + container_div = $("
", { + id: this.container_id, + "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''), + style: 'width: ' + this.f_width + 'px;' + }); + if (this.is_multiple) { + container_div.html('
    '); + } else { + container_div.html('' + this.default_text + '
      '); + } + this.form_field_jq.hide().after(container_div); + this.container = $('#' + this.container_id); + this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single")); + this.dropdown = this.container.find('div.chzn-drop').first(); + dd_top = this.container.height(); + dd_width = this.f_width - get_side_border_padding(this.dropdown); + this.dropdown.css({ + "width": dd_width + "px", + "top": dd_top + "px" + }); + this.search_field = this.container.find('input').first(); + this.search_results = this.container.find('ul.chzn-results').first(); + this.search_field_scale(); + this.search_no_results = this.container.find('li.no-results').first(); + if (this.is_multiple) { + this.search_choices = this.container.find('ul.chzn-choices').first(); + this.search_container = this.container.find('li.search-field').first(); + } else { + this.search_container = this.container.find('div.chzn-search').first(); + this.selected_item = this.container.find('.chzn-single').first(); + sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); + this.search_field.css({ + "width": sf_width + "px" + }); + } + this.results_build(); + this.set_tab_index(); + return this.form_field_jq.trigger("liszt:ready", { + chosen: this + }); + }; + Chosen.prototype.register_observers = function() { + this.container.mousedown(__bind(function(evt) { + return this.container_mousedown(evt); + }, this)); + this.container.mouseup(__bind(function(evt) { + return this.container_mouseup(evt); + }, this)); + this.container.mouseenter(__bind(function(evt) { + return this.mouse_enter(evt); + }, this)); + this.container.mouseleave(__bind(function(evt) { + return this.mouse_leave(evt); + }, this)); + this.search_results.mouseup(__bind(function(evt) { + return this.search_results_mouseup(evt); + }, this)); + this.search_results.mouseover(__bind(function(evt) { + return this.search_results_mouseover(evt); + }, this)); + this.search_results.mouseout(__bind(function(evt) { + return this.search_results_mouseout(evt); + }, this)); + this.form_field_jq.bind("liszt:updated", __bind(function(evt) { + return this.results_update_field(evt); + }, this)); + this.search_field.blur(__bind(function(evt) { + return this.input_blur(evt); + }, this)); + this.search_field.keyup(__bind(function(evt) { + return this.keyup_checker(evt); + }, this)); + this.search_field.keydown(__bind(function(evt) { + return this.keydown_checker(evt); + }, this)); + if (this.is_multiple) { + this.search_choices.click(__bind(function(evt) { + return this.choices_click(evt); + }, this)); + return this.search_field.focus(__bind(function(evt) { + return this.input_focus(evt); + }, this)); + } + }; + Chosen.prototype.search_field_disabled = function() { + this.is_disabled = this.form_field_jq[0].disabled; + if (this.is_disabled) { + this.container.addClass('chzn-disabled'); + this.search_field[0].disabled = true; + if (!this.is_multiple) { + this.selected_item.unbind("focus", this.activate_action); + } + return this.close_field(); + } else { + this.container.removeClass('chzn-disabled'); + this.search_field[0].disabled = false; + if (!this.is_multiple) { + return this.selected_item.bind("focus", this.activate_action); + } + } + }; + Chosen.prototype.container_mousedown = function(evt) { + var target_closelink; + if (!this.is_disabled) { + target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false; + if (evt && evt.type === "mousedown") { + evt.stopPropagation(); + } + if (!this.pending_destroy_click && !target_closelink) { + if (!this.active_field) { + if (this.is_multiple) { + this.search_field.val(""); + } + $(document).click(this.click_test_action); + this.results_show(); + } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) { + evt.preventDefault(); + this.results_toggle(); + } + return this.activate_field(); + } else { + return this.pending_destroy_click = false; + } + } + }; + Chosen.prototype.container_mouseup = function(evt) { + if (evt.target.nodeName === "ABBR") { + return this.results_reset(evt); + } + }; + Chosen.prototype.blur_test = function(evt) { + if (!this.active_field && this.container.hasClass("chzn-container-active")) { + return this.close_field(); + } + }; + Chosen.prototype.close_field = function() { + $(document).unbind("click", this.click_test_action); + if (!this.is_multiple) { + this.selected_item.attr("tabindex", this.search_field.attr("tabindex")); + this.search_field.attr("tabindex", -1); + } + this.active_field = false; + this.results_hide(); + this.container.removeClass("chzn-container-active"); + this.winnow_results_clear(); + this.clear_backstroke(); + this.show_search_field_default(); + return this.search_field_scale(); + }; + Chosen.prototype.activate_field = function() { + if (!this.is_multiple && !this.active_field) { + this.search_field.attr("tabindex", this.selected_item.attr("tabindex")); + this.selected_item.attr("tabindex", -1); + } + this.container.addClass("chzn-container-active"); + this.active_field = true; + this.search_field.val(this.search_field.val()); + return this.search_field.focus(); + }; + Chosen.prototype.test_active_click = function(evt) { + if ($(evt.target).parents('#' + this.container_id).length) { + return this.active_field = true; + } else { + return this.close_field(); + } + }; + Chosen.prototype.results_build = function() { + var content, data, startTime, _i, _len, _ref; + startTime = new Date(); + this.parsing = true; + this.results_data = root.SelectParser.select_to_array(this.form_field); + if (this.is_multiple && this.choices > 0) { + this.search_choices.find("li.search-choice").remove(); + this.choices = 0; + } else if (!this.is_multiple) { + this.selected_item.find("span").text(this.default_text); + if (this.form_field.options.length <= this.disable_search_threshold) { + this.container.addClass("chzn-container-single-nosearch"); + } else { + this.container.removeClass("chzn-container-single-nosearch"); + } + } + content = ''; + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + data = _ref[_i]; + if (data.group) { + content += this.result_add_group(data); + } else if (!data.empty) { + content += this.result_add_option(data); + if (data.selected && this.is_multiple) { + this.choice_build(data); + } else if (data.selected && !this.is_multiple) { + this.selected_item.find("span").text(data.text); + if (this.allow_single_deselect) { + this.single_deselect_control_build(); + } + } + } + } + this.search_field_disabled(); + this.show_search_field_default(); + this.search_field_scale(); + this.search_results.html(content); + return this.parsing = false; + }; + Chosen.prototype.result_add_group = function(group) { + if (!group.disabled) { + group.dom_id = this.container_id + "_g_" + group.array_index; + return '
    • ' + $("
      ").text(group.label).html() + '
    • '; + } else { + return ""; + } + }; + Chosen.prototype.result_do_highlight = function(el) { + var high_bottom, high_top, maxHeight, visible_bottom, visible_top; + if (el.length) { + this.result_clear_highlight(); + this.result_highlight = el; + this.result_highlight.addClass("highlighted"); + maxHeight = parseInt(this.search_results.css("maxHeight"), 10); + visible_top = this.search_results.scrollTop(); + visible_bottom = maxHeight + visible_top; + high_top = this.result_highlight.position().top + this.search_results.scrollTop(); + high_bottom = high_top + this.result_highlight.outerHeight(); + if (high_bottom >= visible_bottom) { + return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0); + } else if (high_top < visible_top) { + return this.search_results.scrollTop(high_top); + } + } + }; + Chosen.prototype.result_clear_highlight = function() { + if (this.result_highlight) { + this.result_highlight.removeClass("highlighted"); + } + return this.result_highlight = null; + }; + Chosen.prototype.results_show = function() { + var dd_top; + if (!this.is_multiple) { + this.selected_item.addClass("chzn-single-with-drop"); + if (this.result_single_selected) { + this.result_do_highlight(this.result_single_selected); + } + } + dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1; + this.dropdown.css({ + "top": dd_top + "px", + "left": 0 + }); + this.results_showing = true; + this.search_field.focus(); + this.search_field.val(this.search_field.val()); + return this.winnow_results(); + }; + Chosen.prototype.results_hide = function() { + if (!this.is_multiple) { + this.selected_item.removeClass("chzn-single-with-drop"); + } + this.result_clear_highlight(); + this.dropdown.css({ + "left": "-9000px" + }); + return this.results_showing = false; + }; + Chosen.prototype.set_tab_index = function(el) { + var ti; + if (this.form_field_jq.attr("tabindex")) { + ti = this.form_field_jq.attr("tabindex"); + this.form_field_jq.attr("tabindex", -1); + if (this.is_multiple) { + return this.search_field.attr("tabindex", ti); + } else { + this.selected_item.attr("tabindex", ti); + return this.search_field.attr("tabindex", -1); + } + } + }; + Chosen.prototype.show_search_field_default = function() { + if (this.is_multiple && this.choices < 1 && !this.active_field) { + this.search_field.val(this.default_text); + return this.search_field.addClass("default"); + } else { + this.search_field.val(""); + return this.search_field.removeClass("default"); + } + }; + Chosen.prototype.search_results_mouseup = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target.length) { + this.result_highlight = target; + return this.result_select(evt); + } + }; + Chosen.prototype.search_results_mouseover = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target) { + return this.result_do_highlight(target); + } + }; + Chosen.prototype.search_results_mouseout = function(evt) { + if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) { + return this.result_clear_highlight(); + } + }; + Chosen.prototype.choices_click = function(evt) { + evt.preventDefault(); + if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) { + return this.results_show(); + } + }; + Chosen.prototype.choice_build = function(item) { + var choice_id, link; + choice_id = this.container_id + "_c_" + item.array_index; + this.choices += 1; + this.search_container.before('
    • ' + item.html + '
    • '); + link = $('#' + choice_id).find("a").first(); + return link.click(__bind(function(evt) { + return this.choice_destroy_link_click(evt); + }, this)); + }; + Chosen.prototype.choice_destroy_link_click = function(evt) { + evt.preventDefault(); + if (!this.is_disabled) { + this.pending_destroy_click = true; + return this.choice_destroy($(evt.target)); + } else { + return evt.stopPropagation; + } + }; + Chosen.prototype.choice_destroy = function(link) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { + this.results_hide(); + } + this.result_deselect(link.attr("rel")); + return link.parents('li').first().remove(); + }; + Chosen.prototype.results_reset = function(evt) { + this.form_field.options[0].selected = true; + this.selected_item.find("span").text(this.default_text); + this.show_search_field_default(); + $(evt.target).remove(); + this.form_field_jq.trigger("change"); + if (this.active_field) { + return this.results_hide(); + } + }; + Chosen.prototype.result_select = function(evt) { + var high, high_id, item, position; + if (this.result_highlight) { + high = this.result_highlight; + high_id = high.attr("id"); + this.result_clear_highlight(); + if (this.is_multiple) { + this.result_deactivate(high); + } else { + this.search_results.find(".result-selected").removeClass("result-selected"); + this.result_single_selected = high; + } + high.addClass("result-selected"); + position = high_id.substr(high_id.lastIndexOf("_") + 1); + item = this.results_data[position]; + item.selected = true; + this.form_field.options[item.options_index].selected = true; + if (this.is_multiple) { + this.choice_build(item); + } else { + this.selected_item.find("span").first().text(item.text); + if (this.allow_single_deselect) { + this.single_deselect_control_build(); + } + } + if (!(evt.metaKey && this.is_multiple)) { + this.results_hide(); + } + this.search_field.val(""); + this.form_field_jq.trigger("change"); + return this.search_field_scale(); + } + }; + Chosen.prototype.result_activate = function(el) { + return el.addClass("active-result"); + }; + Chosen.prototype.result_deactivate = function(el) { + return el.removeClass("active-result"); + }; + Chosen.prototype.result_deselect = function(pos) { + var result, result_data; + result_data = this.results_data[pos]; + result_data.selected = false; + this.form_field.options[result_data.options_index].selected = false; + result = $("#" + this.container_id + "_o_" + pos); + result.removeClass("result-selected").addClass("active-result").show(); + this.result_clear_highlight(); + this.winnow_results(); + this.form_field_jq.trigger("change"); + return this.search_field_scale(); + }; + Chosen.prototype.single_deselect_control_build = function() { + if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) { + return this.selected_item.find("span").first().after(""); + } + }; + Chosen.prototype.winnow_results = function() { + var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref; + startTime = new Date(); + this.no_results_clear(); + results = 0; + searchText = this.search_field.val() === this.default_text ? "" : $('
      ').text($.trim(this.search_field.val())).html(); + regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + if (!option.disabled && !option.empty) { + if (option.group) { + $('#' + option.dom_id).hide(); + } else if (!(this.is_multiple && option.selected)) { + found = false; + result_id = option.dom_id; + if (regex.test(option.html)) { + found = true; + results += 1; + } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { + parts = option.html.replace(/\[|\]/g, "").split(" "); + if (parts.length) { + for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { + part = parts[_j]; + if (regex.test(part)) { + found = true; + results += 1; + } + } + } + } + if (found) { + if (searchText.length) { + startpos = option.html.search(zregex); + text = option.html.substr(0, startpos + searchText.length) + '' + option.html.substr(startpos + searchText.length); + text = text.substr(0, startpos) + '' + text.substr(startpos); + } else { + text = option.html; + } + if ($("#" + result_id).html !== text) { + $("#" + result_id).html(text); + } + this.result_activate($("#" + result_id)); + if (option.group_array_index != null) { + $("#" + this.results_data[option.group_array_index].dom_id).show(); + } + } else { + if (this.result_highlight && result_id === this.result_highlight.attr('id')) { + this.result_clear_highlight(); + } + this.result_deactivate($("#" + result_id)); + } + } + } + } + if (results < 1 && searchText.length) { + return this.no_results(searchText); + } else { + return this.winnow_results_set_highlight(); + } + }; + Chosen.prototype.winnow_results_clear = function() { + var li, lis, _i, _len, _results; + this.search_field.val(""); + lis = this.search_results.find("li"); + _results = []; + for (_i = 0, _len = lis.length; _i < _len; _i++) { + li = lis[_i]; + li = $(li); + _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0); + } + return _results; + }; + Chosen.prototype.winnow_results_set_highlight = function() { + var do_high, selected_results; + if (!this.result_highlight) { + selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : []; + do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first(); + if (do_high != null) { + return this.result_do_highlight(do_high); + } + } + }; + Chosen.prototype.no_results = function(terms) { + var no_results_html; + no_results_html = $('
    • ' + this.results_none_found + ' ""
    • '); + no_results_html.find("span").first().html(terms); + return this.search_results.append(no_results_html); + }; + Chosen.prototype.no_results_clear = function() { + return this.search_results.find(".no-results").remove(); + }; + Chosen.prototype.keydown_arrow = function() { + var first_active, next_sib; + if (!this.result_highlight) { + first_active = this.search_results.find("li.active-result").first(); + if (first_active) { + this.result_do_highlight($(first_active)); + } + } else if (this.results_showing) { + next_sib = this.result_highlight.nextAll("li.active-result").first(); + if (next_sib) { + this.result_do_highlight(next_sib); + } + } + if (!this.results_showing) { + return this.results_show(); + } + }; + Chosen.prototype.keyup_arrow = function() { + var prev_sibs; + if (!this.results_showing && !this.is_multiple) { + return this.results_show(); + } else if (this.result_highlight) { + prev_sibs = this.result_highlight.prevAll("li.active-result"); + if (prev_sibs.length) { + return this.result_do_highlight(prev_sibs.first()); + } else { + if (this.choices > 0) { + this.results_hide(); + } + return this.result_clear_highlight(); + } + } + }; + Chosen.prototype.keydown_backstroke = function() { + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.find("a").first()); + return this.clear_backstroke(); + } else { + this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); + return this.pending_backstroke.addClass("search-choice-focus"); + } + }; + Chosen.prototype.clear_backstroke = function() { + if (this.pending_backstroke) { + this.pending_backstroke.removeClass("search-choice-focus"); + } + return this.pending_backstroke = null; + }; + Chosen.prototype.keydown_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + if (stroke !== 8 && this.pending_backstroke) { + this.clear_backstroke(); + } + switch (stroke) { + case 8: + this.backstroke_length = this.search_field.val().length; + break; + case 9: + if (this.results_showing && !this.is_multiple) { + this.result_select(evt); + } + this.mouse_on_container = false; + break; + case 13: + evt.preventDefault(); + break; + case 38: + evt.preventDefault(); + this.keyup_arrow(); + break; + case 40: + this.keydown_arrow(); + break; + } + }; + Chosen.prototype.search_field_scale = function() { + var dd_top, div, h, style, style_block, styles, w, _i, _len; + if (this.is_multiple) { + h = 0; + w = 0; + style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; + styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; + for (_i = 0, _len = styles.length; _i < _len; _i++) { + style = styles[_i]; + style_block += style + ":" + this.search_field.css(style) + ";"; + } + div = $('
      ', { + 'style': style_block + }); + div.text(this.search_field.val()); + $('body').append(div); + w = div.width() + 25; + div.remove(); + if (w > this.f_width - 10) { + w = this.f_width - 10; + } + this.search_field.css({ + 'width': w + 'px' + }); + dd_top = this.container.height(); + return this.dropdown.css({ + "top": dd_top + "px" + }); + } + }; + Chosen.prototype.generate_random_id = function() { + var string; + string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char(); + while ($("#" + string).length > 0) { + string += this.generate_random_char(); + } + return string; + }; + return Chosen; + })(); + get_side_border_padding = function(elmt) { + var side_border_padding; + return side_border_padding = elmt.outerWidth() - elmt.width(); + }; + root.get_side_border_padding = get_side_border_padding; +}).call(this); diff --git a/app/assets/stylesheets/chosen.css b/app/assets/stylesheets/chosen.css new file mode 100644 index 00000000..7870f053 --- /dev/null +++ b/app/assets/stylesheets/chosen.css @@ -0,0 +1,367 @@ +/* @group Base */ +.chzn-container { + font-size: 13px; + position: relative; + display: inline-block; + zoom: 1; + *display: inline; +} +.chzn-container .chzn-drop { + background: #fff; + border: 1px solid #aaa; + border-top: 0; + position: absolute; + top: 29px; + left: 0; + -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15); + -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15); + -o-box-shadow : 0 4px 5px rgba(0,0,0,.15); + box-shadow : 0 4px 5px rgba(0,0,0,.15); + z-index: 999; +} +/* @end */ + +/* @group Single Chosen */ +.chzn-container-single .chzn-single { + background-color: #fff; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white)); + background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%); + background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%); + background-image: -o-linear-gradient(top, #eeeeee 0%,#ffffff 50%); + background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 50%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 ); + background-image: linear-gradient(top, #eeeeee 0%,#ffffff 50%); + -webkit-border-radius: 4px; + -moz-border-radius : 4px; + border-radius : 4px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; + border: 1px solid #aaa; + display: block; + overflow: hidden; + white-space: nowrap; + position: relative; + height: 26px; + line-height: 26px; + padding: 0 0 0 8px; + color: #444; + text-decoration: none; +} +.chzn-container-single .chzn-single span { + margin-right: 26px; + display: block; + overflow: hidden; + white-space: nowrap; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + text-overflow: ellipsis; +} +.chzn-container-single .chzn-single abbr { + display: block; + position: absolute; + right: 26px; + top: 8px; + width: 12px; + height: 13px; + font-size: 1px; + background: url(chosen-sprite.png) right top no-repeat; +} +.chzn-container-single .chzn-single abbr:hover { + background-position: right -11px; +} +.chzn-container-single .chzn-single div { + -webkit-border-radius: 0 4px 4px 0; + -moz-border-radius : 0 4px 4px 0; + border-radius : 0 4px 4px 0; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; + background: #ccc; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); + background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); + background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); + background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%); + background-image: -ms-linear-gradient(top, #cccccc 0%,#eeeeee 60%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 ); + background-image: linear-gradient(top, #cccccc 0%,#eeeeee 60%); + border-left: 1px solid #aaa; + position: absolute; + right: 0; + top: 0; + display: block; + height: 100%; + width: 18px; +} +.chzn-container-single .chzn-single div b { + background: url('chosen-sprite.png') no-repeat 0 1px; + display: block; + width: 100%; + height: 100%; +} +.chzn-container-single .chzn-search { + padding: 3px 4px; + position: relative; + margin: 0; + white-space: nowrap; + z-index: 1010; +} +.chzn-container-single .chzn-search input { + background: #fff url('chosen-sprite.png') no-repeat 100% -22px; + background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); + background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); + background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); + margin: 1px 0; + padding: 4px 20px 4px 5px; + outline: 0; + border: 1px solid #aaa; + font-family: sans-serif; + font-size: 1em; +} +.chzn-container-single .chzn-drop { + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius : 0 0 4px 4px; + border-radius : 0 0 4px 4px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; +} +/* @end */ + +.chzn-container-single-nosearch .chzn-search input { + position: absolute; + left: -9000px; +} + +/* @group Multi Chosen */ +.chzn-container-multi .chzn-choices { + background-color: #fff; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); + background-image: -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%); + background-image: -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 ); + background-image: linear-gradient(top, #ffffff 85%,#eeeeee 99%); + border: 1px solid #aaa; + margin: 0; + padding: 0; + cursor: text; + overflow: hidden; + height: auto !important; + height: 1%; + position: relative; +} +.chzn-container-multi .chzn-choices li { + float: left; + list-style: none; +} +.chzn-container-multi .chzn-choices .search-field { + white-space: nowrap; + margin: 0; + padding: 0; +} +.chzn-container-multi .chzn-choices .search-field input { + color: #666; + background: transparent !important; + border: 0 !important; + padding: 5px; + margin: 1px 0; + outline: 0; + -webkit-box-shadow: none; + -moz-box-shadow : none; + -o-box-shadow : none; + box-shadow : none; +} +.chzn-container-multi .chzn-choices .search-field .default { + color: #999; +} +.chzn-container-multi .chzn-choices .search-choice { + -webkit-border-radius: 3px; + -moz-border-radius : 3px; + border-radius : 3px; + -moz-background-clip : padding; + -webkit-background-clip: padding-box; + background-clip : padding-box; + background-color: #e4e4e4; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee)); + background-image: -webkit-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%); + background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%); + background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%); + background-image: -ms-linear-gradient(top, #e4e4e4 0%,#eeeeee 70%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4e4e4', endColorstr='#eeeeee',GradientType=0 ); + background-image: linear-gradient(top, #e4e4e4 0%,#eeeeee 70%); + color: #333; + border: 1px solid #b4b4b4; + line-height: 13px; + padding: 3px 19px 3px 6px; + margin: 3px 0 3px 5px; + position: relative; +} +.chzn-container-multi .chzn-choices .search-choice span { + cursor: default; +} +.chzn-container-multi .chzn-choices .search-choice-focus { + background: #d4d4d4; +} +.chzn-container-multi .chzn-choices .search-choice .search-choice-close { + display: block; + position: absolute; + right: 3px; + top: 4px; + width: 12px; + height: 13px; + font-size: 1px; + background: url(chosen-sprite.png) right top no-repeat; +} +.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { + background-position: right -11px; +} +.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close { + background-position: right -11px; +} +/* @end */ + +/* @group Results */ +.chzn-container .chzn-results { + margin: 0 4px 4px 0; + max-height: 190px; + padding: 0 0 0 4px; + position: relative; + overflow-x: hidden; + overflow-y: auto; +} +.chzn-container-multi .chzn-results { + margin: -1px 0 0; + padding: 0; +} +.chzn-container .chzn-results li { + display: none; + line-height: 80%; + padding: 7px 7px 8px; + margin: 0; + list-style: none; +} +.chzn-container .chzn-results .active-result { + cursor: pointer; + display: list-item; +} +.chzn-container .chzn-results .highlighted { + background: #3875d7; + color: #fff; +} +.chzn-container .chzn-results li em { + background: #feffde; + font-style: normal; +} +.chzn-container .chzn-results .highlighted em { + background: transparent; +} +.chzn-container .chzn-results .no-results { + background: #f4f4f4; + display: list-item; +} +.chzn-container .chzn-results .group-result { + cursor: default; + color: #999; + font-weight: bold; +} +.chzn-container .chzn-results .group-option { + padding-left: 20px; +} +.chzn-container-multi .chzn-drop .result-selected { + display: none; +} +/* @end */ + +/* @group Active */ +.chzn-container-active .chzn-single { + -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); + -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); + -o-box-shadow : 0 0 5px rgba(0,0,0,.3); + box-shadow : 0 0 5px rgba(0,0,0,.3); + border: 1px solid #5897fb; +} +.chzn-container-active .chzn-single-with-drop { + border: 1px solid #aaa; + -webkit-box-shadow: 0 1px 0 #fff inset; + -moz-box-shadow : 0 1px 0 #fff inset; + -o-box-shadow : 0 1px 0 #fff inset; + box-shadow : 0 1px 0 #fff inset; + background-color: #eee; + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee)); + background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%); + background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%); + background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%); + background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 ); + background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%); + -webkit-border-bottom-left-radius : 0; + -webkit-border-bottom-right-radius: 0; + -moz-border-radius-bottomleft : 0; + -moz-border-radius-bottomright: 0; + border-bottom-left-radius : 0; + border-bottom-right-radius: 0; +} +.chzn-container-active .chzn-single-with-drop div { + background: transparent; + border-left: none; +} +.chzn-container-active .chzn-single-with-drop div b { + background-position: -18px 1px; +} +.chzn-container-active .chzn-choices { + -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3); + -moz-box-shadow : 0 0 5px rgba(0,0,0,.3); + -o-box-shadow : 0 0 5px rgba(0,0,0,.3); + box-shadow : 0 0 5px rgba(0,0,0,.3); + border: 1px solid #5897fb; +} +.chzn-container-active .chzn-choices .search-field input { + color: #111 !important; +} +/* @end */ + +/* @group Disabled Support */ +.chzn-disabled { + cursor: default; + opacity:0.5 !important; +} +.chzn-disabled .chzn-single { + cursor: default; +} +.chzn-disabled .chzn-choices .search-choice .search-choice-close { + cursor: default; +} + +/* @group Right to Left */ +.chzn-rtl { direction:rtl;text-align: right; } +.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; } +.chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; } +.chzn-rtl .chzn-single div { + left: 0; right: auto; + border-left: none; border-right: 1px solid #aaaaaa; + -webkit-border-radius: 4px 0 0 4px; + -moz-border-radius : 4px 0 0 4px; + border-radius : 4px 0 0 4px; +} +.chzn-rtl .chzn-choices li { float: right; } +.chzn-rtl .chzn-choices .search-choice { padding: 3px 6px 3px 19px; margin: 3px 5px 3px 0; } +.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 5px; right: auto; background-position: right top;} +.chzn-rtl.chzn-container-single .chzn-results { margin-left: 4px; margin-right: 0; padding-left: 0; padding-right: 4px; } +.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; } +.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; } +.chzn-rtl .chzn-search input { + background: url('chosen-sprite.png') no-repeat -38px -22px, #ffffff; + background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); + background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); + background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%); + background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%); + padding: 4px 5px 4px 20px; +} +/* @end */ diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index d8e04318..4e4bcccc 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -706,3 +706,16 @@ table.highlighttable pre{ line-height:16px !important; font-size:12px !important; } + +.project-refs-form { + span { + background: none !important; + position:static !important; + width:auto !important; + height: auto !important; + } +} + +.project-refs-select { + width:200px; +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0bf38a57..6d0edace 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -57,19 +57,13 @@ class ApplicationController < ActionController::Base end def load_refs - @branch = unless params[:branch].blank? - params[:branch] - else - nil - end - - @tag = unless params[:tag].blank? - params[:tag] - else - nil - end - - @ref = @branch || @tag || "master" + unless params[:ref].blank? + @ref = params[:ref] + else + @branch = params[:branch].blank? ? nil : params[:branch] + @tag = params[:tag].blank? ? nil : params[:tag] + @ref = @branch || @tag || "master" + end end def render_404 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef92953d..3aa40c99 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,6 +32,15 @@ module ApplicationHelper "Never" end + def grouped_options_refs + options = [ + ["Branch", @repo.heads.map(&:name) ], + [ "Tag", @project.tags ] + ] + + grouped_options_for_select(options, @ref) + end + def markdown(text) RDiscount.new(text, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe end diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index f8928b6f..7999b94c 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -1,33 +1,18 @@ - content_for(:body_class, "project-page commits-page") -.left - = form_tag project_commits_path(@project), :method => :get do - = select_tag "branch", options_for_select(@repo.heads.map(&:name), @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Branches" -.left - = form_tag project_commits_path(@project), :method => :get do - = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" -.clear - -%br - - -#%a.right.button{:href => "#"} Download -#-if can? current_user, :admin_project, @project %a.right.button.blue{:href => "#"} EDIT %h2.icon %span - %a.project-name{:href => "#"} - %i.arrow> - Project -   %d - %a{:href => "#"} - = @ref - - if params[:path] -   - %d + = link_to project_commits_path(@project) do + = @project.name + - if params[:path] + \/ %a{:href => "#"}= params[:path].split("/").join(" / ") +.right= render "projects/refs" %div{:id => dom_id(@project)} = render "commits" diff --git a/app/views/projects/_refs.html.haml b/app/views/projects/_refs.html.haml new file mode 100644 index 00000000..f7712d3d --- /dev/null +++ b/app/views/projects/_refs.html.haml @@ -0,0 +1,8 @@ += form_tag project_commits_path(@project), :method => :get, :class => "project-refs-form" do + = select_tag "ref", grouped_options_refs, :onchange => "this.form.submit();", :class => "project-refs-select" + + +:javascript + $(function(){ + $('.project-refs-select').chosen(); + }) diff --git a/app/views/projects/_tree.html.haml b/app/views/projects/_tree.html.haml index 2aca18e4..f70bbb7a 100644 --- a/app/views/projects/_tree.html.haml +++ b/app/views/projects/_tree.html.haml @@ -1,12 +1,3 @@ -.left - = form_tag tree_project_path(@project), :method => :get do - = select_tag "branch", options_for_select(@repo.heads.map(&:name), @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Branches" -.left - = form_tag tree_project_path(@project), :method => :get do - = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" -.clear - -%br -#%a.right.button{:href => "#"} Download -#-if can? current_user, :admin_project, @project @@ -14,14 +5,9 @@ #tree-breadcrumbs %h2.icon %span - = link_to tree_project_path(@project, :path => nil, :commit_id => @commit.try(:id)), :remote => true, :class => 'project-name' do - %i.arrow> - = @project.name -   %d - %a{:href => "#"} - = @ref - + = link_to tree_project_path(@project, :path => nil, :commit_id => @commit.try(:id)), :remote => true do + = @project.name - if params[:path] - part_path = "" - params[:path].split("\/").each do |part| @@ -30,7 +16,8 @@ - part_path = part \/ = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id), :branch => @branch, :tag => @tag), :remote => :true - +   + .right= render "projects/refs" .clear #tree-content-holder From a9639776d7c52ca63c5ca7b86baf300b1a5e87e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 4 Nov 2011 00:37:02 +0200 Subject: [PATCH 03/24] fixed/fluid layout switch --- app/assets/stylesheets/style.scss | 2 +- app/controllers/application_controller.rb | 10 +++++ app/helpers/application_helper.rb | 8 ++++ app/views/layouts/_head_panel.html.erb | 51 +++++++++++------------ app/views/layouts/admin.html.haml | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/layouts/profile.html.haml | 2 +- app/views/layouts/project.html.haml | 2 +- 8 files changed, 47 insertions(+), 32 deletions(-) diff --git a/app/assets/stylesheets/style.scss b/app/assets/stylesheets/style.scss index 97be566f..29e6058d 100755 --- a/app/assets/stylesheets/style.scss +++ b/app/assets/stylesheets/style.scss @@ -292,7 +292,7 @@ body.login-page{background-color: #f1f1f1; padding-top: 10%} /* General */ #container{background-color: white; overflow: hidden;} -/*#container{margin: auto; width: 980px; border: 1px solid rgba(0,0,0,.22); border-top: 0; box-shadow: 0 0 0px 4px rgba(0,0,0,.04)}*/ +body.collapsed #container{margin: auto; width: 980px; border: 1px solid rgba(0,0,0,.22); border-top: 0; box-shadow: 0 0 0px 4px rgba(0,0,0,.04)} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6d0edace..070def96 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,7 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! + before_filter :view_style + protect_from_forgery helper_method :abilities, :can? @@ -73,4 +75,12 @@ class ApplicationController < ActionController::Base def require_non_empty_project redirect_to @project unless @project.repo_exists? end + + def view_style + if params[:view_style] == "collapsed" + cookies[:view_style] = "collapsed" + elsif params[:view_style] == "fluid" + cookies[:view_style] = "" + end + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3aa40c99..70984804 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,6 +4,14 @@ module ApplicationHelper "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" end + def body_class(default_class = nil) + main = content_for(:body_class).blank? ? + default_class : + content_for(:body_class) + + [main, cookies[:view_style]].join(" ") + end + def commit_name(project, commit) if project.commit.id == commit.id "master" diff --git a/app/views/layouts/_head_panel.html.erb b/app/views/layouts/_head_panel.html.erb index a64aa3b5..6db1d389 100644 --- a/app/views/layouts/_head_panel.html.erb +++ b/app/views/layouts/_head_panel.html.erb @@ -1,19 +1,29 @@
      -

      - GITLAB

      -
      - - <% if current_user %> <%= javascript_tag do %> $(function() { diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 8df7881c..e02dbe04 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -9,7 +9,7 @@ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; - %body{ :class => content_for?(:body_class) ? yield(:body_class) : 'project-page', :id => yield(:boyd_id)} + %body{ :class => body_class('project-page'), :id => yield(:boyd_id)} #container = render :partial => "layouts/flash" = render :partial => "layouts/head_panel" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index eedbf116..030f1999 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,7 +13,7 @@ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; - %body{ :class => yield(:body_class), :id => yield(:boyd_id)} + %body{ :class => body_class, :id => yield(:boyd_id)} #container = render :partial => "layouts/flash" = render :partial => "layouts/head_panel" diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index a33d9d5d..2fd30dcd 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -9,7 +9,7 @@ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; - %body{ :class => content_for?(:body_class) ? yield(:body_class) : 'project-page', :id => yield(:boyd_id)} + %body{ :class => body_class('project-page'), :id => yield(:boyd_id)} #container = render :partial => "layouts/flash" = render :partial => "layouts/head_panel" diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index f8d8221a..ee6581ec 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -9,7 +9,7 @@ = javascript_tag do REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_REFFER = "#{request.env["HTTP_REFERER"]}"; - %body{ :class => content_for?(:body_class) ? yield(:body_class) : 'project-page', :id => yield(:boyd_id)} + %body{ :class => body_class('project-page'), :id => yield(:boyd_id)} #container = render :partial => "layouts/flash" = render :partial => "layouts/head_panel" From 5d526717d626c072b6eb522e132cc30d9d96d60b Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 4 Nov 2011 01:16:12 +0200 Subject: [PATCH 04/24] increase max size of public to 1600 bytes --- app/models/key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/key.rb b/app/models/key.rb index 1559b5bd..5fe30734 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -8,7 +8,7 @@ class Key < ActiveRecord::Base validates :key, :presence => true, :uniqueness => true, - :length => { :within => 0..1024 } + :length => { :within => 0..1600 } before_save :set_identifier after_save :update_gitosis From 6977150f04be1bfe365e1cd86e3f8143c34a51bf Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 4 Nov 2011 09:42:36 +0200 Subject: [PATCH 05/24] integrate tags plugins --- Gemfile | 2 + Gemfile.lock | 3 + app/models/project.rb | 2 + ...101222453_acts_as_taggable_on_migration.rb | 28 ++++ vendor/assets/javascripts/jquery.tagify.js | 143 ++++++++++++++++++ .../stylesheets/jquery-ui/jquery.tagify.css | 34 +++++ 6 files changed, 212 insertions(+) create mode 100644 db/migrate/20111101222453_acts_as_taggable_on_migration.rb create mode 100644 vendor/assets/javascripts/jquery.tagify.js create mode 100644 vendor/assets/stylesheets/jquery-ui/jquery.tagify.css diff --git a/Gemfile b/Gemfile index 8da55b10..f32c13f0 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,8 @@ gem "git" gem "acts_as_list" gem 'rdiscount' +gem 'acts-as-taggable-on', '~>2.1.0' + group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" diff --git a/Gemfile.lock b/Gemfile.lock index f66e832e..e557ee43 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,6 +54,8 @@ GEM activesupport (= 3.1.0) activesupport (3.1.0) multi_json (~> 1.0) + acts-as-taggable-on (2.1.1) + rails acts_as_list (0.1.4) addressable (2.2.6) ansi (1.3.0) @@ -246,6 +248,7 @@ PLATFORMS ruby DEPENDENCIES + acts-as-taggable-on (~> 2.1.0) acts_as_list annotate! autotest diff --git a/app/models/project.rb b/app/models/project.rb index befa1c6b..de68f451 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -9,6 +9,8 @@ class Project < ActiveRecord::Base has_many :notes, :dependent => :destroy has_many :snippets, :dependent => :destroy + acts_as_taggable + validates :name, :uniqueness => true, :presence => true, diff --git a/db/migrate/20111101222453_acts_as_taggable_on_migration.rb b/db/migrate/20111101222453_acts_as_taggable_on_migration.rb new file mode 100644 index 00000000..16610615 --- /dev/null +++ b/db/migrate/20111101222453_acts_as_taggable_on_migration.rb @@ -0,0 +1,28 @@ +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + end + + create_table :taggings do |t| + t.references :tag + + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, :polymorphic => true + t.references :tagger, :polymorphic => true + + t.string :context + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/vendor/assets/javascripts/jquery.tagify.js b/vendor/assets/javascripts/jquery.tagify.js new file mode 100644 index 00000000..f22d4c71 --- /dev/null +++ b/vendor/assets/javascripts/jquery.tagify.js @@ -0,0 +1,143 @@ +/* Author: Alicia Liu */ + +(function ($) { + + $.widget("ui.tagify", { + options: { + delimiters: [13, 188], // what user can type to complete a tag in char codes: [enter], [comma] + outputDelimiter: ',', // delimiter for tags in original input field + cssClass: 'tagify-container', // CSS class to style the tagify div and tags, see stylesheet + addTagPrompt: 'add tags' // placeholder text + }, + + _create: function() { + var self = this, + el = self.element, + opts = self.options; + + this.tags = []; + + // hide text field and replace with a div that contains it's own input field for entering tags + this.tagInput = $("") + .attr( 'placeholder', opts.addTagPrompt ) + .keypress( function(e) { + var $this = $(this), + pressed = e.which; + + for ( i in opts.delimiters ) { + + if (pressed == opts.delimiters[i]) { + self.add( $this.val() ); + e.preventDefault(); + return false; + } + } + }) + // for some reason, in Safari, backspace is only recognized on keyup + .keyup( function(e) { + var $this = $(this), + pressed = e.which; + + // if backspace is hit with no input, remove the last tag + if (pressed == 8) { // backspace + if ( $this.val() == "" ) { + self.remove(); + return false; + } + return; + } + }); + + this.tagDiv = $("
      ") + .addClass( opts.cssClass ) + .click( function() { + $(this).children('input').focus(); + }) + .append( this.tagInput ) + .insertAfter( el.hide() ); + + // if the field isn't empty, parse the field for tags, and prepopulate existing tags + var initVal = $.trim( el.val() ); + + if ( initVal ) { + var initTags = initVal.split( opts.outputDelimiter ); + $.each( initTags, function(i, tag) { + self.add( tag ); + }); + } + }, + + _setOption: function( key, value ) { + options.key = value; + }, + + // add a tag, public function + add: function(text) { + var self = this; + text = text || self.tagInput.val(); + if (text) { + var tagIndex = self.tags.length; + + var removeButton = $("x") + .click( function() { + self.remove( tagIndex ); + return false; + }); + var newTag = $("") + .text( text ) + .append( removeButton ); + + self.tagInput.before( newTag ); + self.tags.push( text ); + self.tagInput.val(''); + } + }, + + // remove a tag by index, public function + // if index is blank, remove the last tag + remove: function( tagIndex ) { + var self = this; + if ( tagIndex == null || tagIndex === (self.tags.length - 1) ) { + this.tagDiv.children("span").last().remove(); + self.tags.pop(); + } + if ( typeof(tagIndex) == 'number' ) { + // otherwise just hide this tag, and we don't mess up the index + this.tagDiv.children( "span:eq(" + tagIndex + ")" ).hide(); + // we rely on the serialize function to remove null values + delete( self.tags[tagIndex] ); + } + }, + + // serialize the tags with the given delimiter, and write it back into the tagified field + serialize: function() { + var self = this; + var delim = self.options.outputDelimiter; + var tagsStr = self.tags.join( delim ); + + // our tags might have deleted entries, remove them here + var dupes = new RegExp(delim + delim + '+', 'g'); // regex: /,,+/g + var ends = new RegExp('^' + delim + '|' + delim + '$', 'g'); // regex: /^,|,$/g + var outputStr = tagsStr.replace( dupes, delim ).replace(ends, ''); + + self.element.val(outputStr); + return outputStr; + }, + + inputField: function() { + return this.tagInput; + }, + + containerDiv: function() { + return this.tagDiv; + }, + + // remove the div, and show original input + destroy: function() { + $.Widget.prototype.destroy.apply(this); + this.tagDiv.remove(); + this.element.show(); + } + }); + +})(jQuery); \ No newline at end of file diff --git a/vendor/assets/stylesheets/jquery-ui/jquery.tagify.css b/vendor/assets/stylesheets/jquery-ui/jquery.tagify.css new file mode 100644 index 00000000..d6c178f7 --- /dev/null +++ b/vendor/assets/stylesheets/jquery-ui/jquery.tagify.css @@ -0,0 +1,34 @@ +/* Tagify styles +Author: Alicia Liu test +*/ + +.tagify-container { +} + +.tagify-container > span { + display: inline-block; + padding: 8px 11px 8px 11px; + margin: 1px 5px 0px 0px; + border-radius: 4px; + border: 1px solid #d0e1ff; + background-color: #d0e1ff; + color: #0f326d; + font-weight: bold; + font-size: 14px; +} + +.tagify-container > span > a { + padding-left: 5px !important; + color: #83a5e1; + text-decoration: none; + font-weight: bold; +} + +.tagify-container > input { + border: 0 none; + width: 100px !important; +} + +.tagify-container > input:focus { + outline: none; +} \ No newline at end of file From 687290a00d71540ae809ae9ef172771ce7c46778 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 4 Nov 2011 09:46:58 +0200 Subject: [PATCH 06/24] fixed brach switch --- app/views/commits/index.html.haml | 2 +- app/views/projects/_refs.html.haml | 2 +- app/views/projects/_tree.html.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index 7999b94c..b9650145 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -12,7 +12,7 @@ \/ %a{:href => "#"}= params[:path].split("/").join(" / ") -.right= render "projects/refs" +.right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) } %div{:id => dom_id(@project)} = render "commits" diff --git a/app/views/projects/_refs.html.haml b/app/views/projects/_refs.html.haml index f7712d3d..60b17c7f 100644 --- a/app/views/projects/_refs.html.haml +++ b/app/views/projects/_refs.html.haml @@ -1,4 +1,4 @@ -= form_tag project_commits_path(@project), :method => :get, :class => "project-refs-form" do += form_tag destination, :method => :get, :class => "project-refs-form" do = select_tag "ref", grouped_options_refs, :onchange => "this.form.submit();", :class => "project-refs-select" diff --git a/app/views/projects/_tree.html.haml b/app/views/projects/_tree.html.haml index f70bbb7a..8fdf72f0 100644 --- a/app/views/projects/_tree.html.haml +++ b/app/views/projects/_tree.html.haml @@ -17,7 +17,7 @@ \/ = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id), :branch => @branch, :tag => @tag), :remote => :true   - .right= render "projects/refs" + .right= render :partial => "projects/refs", :locals => { :destination => tree_project_path(@project) } .clear #tree-content-holder From b946da44695c9c8fe8867bb87bcdf801c52177d3 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 4 Nov 2011 10:11:14 +0200 Subject: [PATCH 07/24] added tags to form --- app/assets/javascripts/application.js | 1 + app/assets/stylesheets/application.css | 1 + app/views/projects/_form.html.haml | 17 +++++++++++++++++ db/schema.rb | 19 ++++++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 86887fdd..b1e95736 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -8,6 +8,7 @@ //= require jquery-ui //= require jquery_ujs //= require jquery.ui.selectmenu +//= require jquery.tagify //= require jquery.cookie //= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 777f3fc1..e170dc07 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -4,6 +4,7 @@ * the top of the compiled file, but it's generally better to create a new file per style scope. *= require jquery-ui/jquery-ui *= require jquery-ui/jquery.ui.selectmenu + *= require jquery-ui/jquery.tagify *= require_self *= require_tree . */ diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 164f1d45..605a2f45 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -25,6 +25,11 @@ .left= f.label :code %cite.right http://yourserver/ %td= f.text_field :code, :placeholder => "example" + + %tr + %td= f.label :tag_list + %td= f.text_area :tag_list, :placeholder => "project tags", :style => "height:50px", :id => :tag_field + .field = f.label :description %br/ @@ -41,8 +46,20 @@ %h3.prepend-top Creating project & repository. Please wait for few minutes - else %h3.prepend-top Updating project & repository. Please wait for few minutes + :javascript $('.new_project, .edit_project').bind('ajax:before', function() { $(this).find(".form_content").hide(); $('.ajax_loader').show(); }); + +:javascript + $(function(){ + var tag_field = $('#tag_field').tagify(); + + $('form').submit( function() { + var tag_field = $('#tag_field') + tag_field.val( tag_field.tagify('serialize') ); + return true; + }); + }) diff --git a/db/schema.rb b/db/schema.rb index 13c4db0c..3d430f4c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111027152724) do +ActiveRecord::Schema.define(:version => 20111101222453) do create_table "issues", :force => true do |t| t.string "title" @@ -68,6 +68,23 @@ ActiveRecord::Schema.define(:version => 20111027152724) do t.datetime "expires_at" end + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context" + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + + create_table "tags", :force => true do |t| + t.string "name" + end + create_table "users", :force => true do |t| t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false From ca1e3d05796484424057d071b726779537868384 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 4 Nov 2011 09:37:38 -0400 Subject: [PATCH 08/24] wall login in progress --- app/assets/images/ajax-loader.gif | Bin 6820 -> 4178 bytes app/assets/javascripts/application.js | 4 +- app/assets/javascripts/note.js | 65 +++++++++++++++++++++++ app/assets/stylesheets/projects.css.scss | 45 ++++------------ app/controllers/projects_controller.rb | 14 ++--- app/views/notes/_notes.html.haml | 4 +- app/views/notes/_show.html.haml | 20 ++++--- app/views/notes/create.js.haml | 1 - app/views/projects/wall.html.haml | 20 ++----- app/views/projects/wall.js.haml | 11 +++- 10 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 app/assets/javascripts/note.js diff --git a/app/assets/images/ajax-loader.gif b/app/assets/images/ajax-loader.gif index 0ca7ada960568fff04400cda966fbdcb106abfa2..c97ec6ea9739a68e25637c0aa4adaaea05e3e4ca 100644 GIT binary patch literal 4178 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 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 86887fdd..23845ea5 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,6 +20,6 @@ $(function(){ $('select#tag').selectmenu({style:'popup', width:200}); }); -function updatePage(){ - $.ajax({type: "GET", url: location.href, dataType: "script"}); +function updatePage(data){ + $.ajax({type: "GET", url: location.href, data: data, dataType: "script"}); } diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js new file mode 100644 index 00000000..71279fc4 --- /dev/null +++ b/app/assets/javascripts/note.js @@ -0,0 +1,65 @@ +var NoteList = { + +first_id: 0, +last_id: 0, +resource_name: null, + +init: + function(resource_name, first_id, last_id) { + this.resource_name = resource_name; + this.first_id = first_id; + this.last_id = last_id; + this.initRefresh(); + this.initLoadMore(); + }, + +getOld: + function() { + $('.loading').show(); + $.ajax({ + type: "GET", + url: location.href, + data: "first_id=" + this.first_id, + complete: function(){ $('.loading').hide()}, + dataType: "script"}); + }, + +append: + function(id, html) { + this.first_id = id; + $("#notes-list").append(html); + this.initLoadMore(); + }, + +prepend: + function(id, html) { + this.last_id = id; + $("#notes-list").prepend(html); + }, + +getNew: + function() { + // refersh notes list + $.ajax({ + type: "GET", + url: location.href, + data: "last_id=" + this.last_id, + dataType: "script"}); + }, + +initRefresh: + function() { + // init timer + var int = setInterval("NoteList.getNew()", 20000); + }, + +initLoadMore: + function() { + $(window).bind('scroll', function(){ + if($(window).scrollTop() == $(document).height() - $(window).height()){ + $(window).unbind('scroll'); + NoteList.getOld(); + } + }); + } +} diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 4e4bcccc..06063b16 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -421,31 +421,6 @@ input.ssh_project_url { list-style:none; margin:0px; padding:0px; - - li { - display:list-item; - padding:8px; - margin:0px; - background: #F7FBFC; - border-top: 1px solid #E2EAEE; - - &:first-child { - border-top: none; - } - &:nth-child(2n+1) { - background: white; - } - p { - margin-bottom: 4px; - font-size: 13px; - color:#111; - } - } - cite { - &.ago { - color:#666; - } - } } .notes_count { @@ -460,14 +435,6 @@ input.ssh_project_url { right: 6px; top: 6px; } -.note_author { - float:left; - width:60px; -} -.note_content { - float:left; - width:650px; -} .issue_notes { .note_content { @@ -556,8 +523,7 @@ input.ssh_project_url { } .commit, -.message, -#notes-list{ +.message{ .author { background: #eaeaea; color: #333; @@ -719,3 +685,12 @@ table.highlighttable pre{ .project-refs-select { width:200px; } + + +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} +body.project-page #notes-list .note img{float: left; margin-right: 10px;} +body.project-page #notes-list .note span.note-title{display: block;} +body.project-page #notes-list .note span.note-title{margin-bottom: 10px} +body.project-page #notes-list .note span.note-author{color: #999; font-weight: normal; font-style: italic;} +body.project-page #notes-list .note span.note-author strong{font-weight: bold; font-style: normal;} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e046add3..067245c4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,13 +86,15 @@ class ProjectsController < ApplicationController def wall @note = Note.new @notes = @project.common_notes.order("created_at DESC") + @notes = @notes.fresh.limit(20) - @notes = case params[:view] - when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day) - when "all" then @notes.all - when "day" then @notes.since(Date.today.at_beginning_of_day) - else @notes.fresh.limit(10) - end + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end + end end # diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index e7cc2360..e33050b0 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -20,8 +20,8 @@ $("#submit_note").removeAttr("disabled"); }) -- if ["issues", "projects"].include?(controller.controller_name) +-#- if ["issues", "projects"].include?(controller.controller_name) :javascript $(function(){ - var int =self.setInterval("updatePage()", 20000); + var int =self.setInterval("updatePage('ref=#{params[:ref]}')", 20000); }); diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index 187d0a3c..164733a5 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -1,17 +1,15 @@ -%li{:id => dom_id(note)} - %div.note_author - = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" - %div.note_content.left +%li{:id => dom_id(note), :class => "note"} + = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" + %div.note-author + %strong= note.author_name + = time_ago_in_words(note.updated_at) + - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) + = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" + + %div.note-title = markdown(note.note) - if note.attachment.url Attachment: = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" - %br - %span.author= note.author.name - %cite.ago - = time_ago_in_words(note.updated_at) - ago %br - - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) - = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" .clear diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml index a04130e8..ffc80140 100644 --- a/app/views/notes/create.js.haml +++ b/app/views/notes/create.js.haml @@ -1,7 +1,6 @@ - if @note.valid? :plain $("#new_note .errors").remove(); - updatePage(); $('#note_note').val(""); - else :plain diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index 63c9613a..2bc3150a 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -1,29 +1,19 @@ %div.wall_page - if can? current_user, :write_note, @project = render "notes/form" - .right - = form_tag wall_project_path(@project), :method => :get do - .span-2 - = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" - = label_tag "recent_view","Recent" - .span-2 - = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" - = label_tag "day_view","Today" - .span-2 - = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" - = label_tag "week_view","Week" - .span-2 - = radio_button_tag :view, "all", params[:view] == "all", :onclick => "this.form.submit()", :id => "all_view" - = label_tag "all_view","All" .clear - %br %hr = render "notes/notes" +.loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" + :javascript $(function(){ $("#note_note").live("click", function(){ $(this).css("height", "100px"); $('.attach_holder').show(); }); + + NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); }); diff --git a/app/views/projects/wall.js.haml b/app/views/projects/wall.js.haml index ae2ff32c..81417800 100644 --- a/app/views/projects/wall.js.haml +++ b/app/views/projects/wall.js.haml @@ -1,2 +1,9 @@ -:plain - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); +- unless @notes.blank? + + - if params[:last_id] + :plain + NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); + + - if params[:first_id] + :plain + NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); From 8a23682fc5212918c931888bb7b468d167d19c33 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 4 Nov 2011 11:46:51 -0400 Subject: [PATCH 09/24] refactored too --- app/assets/stylesheets/projects.css.scss | 2 +- app/controllers/commits_controller.rb | 11 +++++++---- app/controllers/issues_controller.rb | 10 +++++++++- app/views/commits/show.js.haml | 9 +-------- app/views/issues/show.html.haml | 13 +++++++++++- app/views/issues/show.js.haml | 3 +-- app/views/notes/_load.js.haml | 10 ++++++++++ app/views/notes/_notes.html.haml | 25 ++++++++++++------------ app/views/notes/create.js.haml | 1 + app/views/projects/wall.html.haml | 15 +------------- app/views/projects/wall.js.haml | 10 +--------- 11 files changed, 56 insertions(+), 53 deletions(-) create mode 100644 app/views/notes/_load.js.haml diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 06063b16..ba18bfa0 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -540,7 +540,7 @@ input.ssh_project_url { font-size:14px; } -.wall_page { +#new_note { #note_note { height:25px; } diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 79b97ed7..f6af56f8 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -28,12 +28,15 @@ class CommitsController < ApplicationController def show @commit = project.repo.commits(params[:id]).first - @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit") + @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit").order("created_at DESC").limit(20) @note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit") - respond_to do |format| - format.html # show.html.erb - format.js + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end end end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 71c559a1..b6fd85b8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -35,8 +35,16 @@ class IssuesController < ApplicationController end def show - @notes = @issue.notes.order("created_at ASC") + @notes = @issue.notes.order("created_at DESC").limit(20) @note = @project.notes.new(:noteable => @issue) + + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end + end end def create diff --git a/app/views/commits/show.js.haml b/app/views/commits/show.js.haml index 9831bb29..ee31c0b8 100644 --- a/app/views/commits/show.js.haml +++ b/app/views/commits/show.js.haml @@ -1,8 +1 @@ --#:plain - $("#side-commit-preview").remove(); - var side = $("
      "); - side.html("#{escape_javascript(render "commits/show")}"); - $("##{dom_id(@project)}").parent().append(side); - $("##{dom_id(@project)}").addClass("span-14"); -:plain - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); += render "notes/load" diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 371a8033..669784ba 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,8 +1,10 @@ %h2 = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" .left.width-65p - -#= simple_format html_escape(@issue.content) .issue_notes= render "notes/notes" + + .loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" .right.width-30p .span-8 - if @issue.closed @@ -55,3 +57,12 @@ .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .clear +:javascript + $(function(){ + $("#note_note").live("click", function(){ + $(this).css("height", "100px"); + $('.attach_holder').show(); + }); + + NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); + }); diff --git a/app/views/issues/show.js.haml b/app/views/issues/show.js.haml index ae2ff32c..ee31c0b8 100644 --- a/app/views/issues/show.js.haml +++ b/app/views/issues/show.js.haml @@ -1,2 +1 @@ -:plain - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); += render "notes/load" diff --git a/app/views/notes/_load.js.haml b/app/views/notes/_load.js.haml new file mode 100644 index 00000000..f560f0bd --- /dev/null +++ b/app/views/notes/_load.js.haml @@ -0,0 +1,10 @@ +- unless @notes.blank? + + - if params[:last_id] + :plain + NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); + + - if params[:first_id] + :plain + NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); + diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index e33050b0..4a5c3aab 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -1,12 +1,8 @@ -- if controller.action_name == "wall" - %ul#notes-list= render "notes/notes_list" - -- else - %ul#notes-list= render "notes/notes_list" - %br - %br - - if can? current_user, :write_note, @project - = render "notes/form" +- if can? current_user, :write_note, @project + = render "notes/form" +.clear +%hr +%ul#notes-list= render "notes/notes_list" :javascript $('.delete-note').live('ajax:success', function() { @@ -20,8 +16,11 @@ $("#submit_note").removeAttr("disabled"); }) --#- if ["issues", "projects"].include?(controller.controller_name) - :javascript - $(function(){ - var int =self.setInterval("updatePage('ref=#{params[:ref]}')", 20000); + $(function(){ + $("#note_note").live("click", function(){ + $(this).css("height", "100px"); + $('.attach_holder').show(); }); + + NoteList.init("wall", #{@notes.last.try(:id) || 0}, #{@notes.first.try(:id) || 0}); + }); diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml index ffc80140..cf804493 100644 --- a/app/views/notes/create.js.haml +++ b/app/views/notes/create.js.haml @@ -2,6 +2,7 @@ :plain $("#new_note .errors").remove(); $('#note_note').val(""); + NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}"); - else :plain $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index 2bc3150a..4f0ec41e 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -1,19 +1,6 @@ %div.wall_page - - if can? current_user, :write_note, @project - = render "notes/form" - .clear - %hr -= render "notes/notes" + = render "notes/notes" .loading{ :style => "display:none;"} %center= image_tag "ajax-loader.gif" -:javascript - $(function(){ - $("#note_note").live("click", function(){ - $(this).css("height", "100px"); - $('.attach_holder').show(); - }); - - NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); - }); diff --git a/app/views/projects/wall.js.haml b/app/views/projects/wall.js.haml index 81417800..ee31c0b8 100644 --- a/app/views/projects/wall.js.haml +++ b/app/views/projects/wall.js.haml @@ -1,9 +1 @@ -- unless @notes.blank? - - - if params[:last_id] - :plain - NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); - - - if params[:first_id] - :plain - NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); += render "notes/load" From 2ed5211dad88dc0b0cccb1104ed2180192609950 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 4 Nov 2011 11:59:00 -0400 Subject: [PATCH 10/24] fixes --- app/views/issues/show.html.haml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 669784ba..7321f635 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -56,13 +56,3 @@ = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .clear - -:javascript - $(function(){ - $("#note_note").live("click", function(){ - $(this).css("height", "100px"); - $('.attach_holder').show(); - }); - - NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); - }); From 0b0e0225adfc83ed951118b3c3e82167add9fd03 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 4 Nov 2011 12:20:52 -0400 Subject: [PATCH 11/24] css fixes --- app/assets/stylesheets/projects.css.scss | 1 - app/views/issues/show.html.haml | 4 ---- app/views/notes/_show.html.haml | 4 +++- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index ba18bfa0..766138ee 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -686,7 +686,6 @@ table.highlighttable pre{ width:200px; } - body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 7321f635..8267a850 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -7,10 +7,6 @@ %center= image_tag "ajax-loader.gif" .right.width-30p .span-8 - - if @issue.closed - %center.success Closed - - else - %center.error Open %table.round-borders %tr %td Title: diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index 164733a5..5d766291 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -2,7 +2,9 @@ = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" %div.note-author %strong= note.author_name - = time_ago_in_words(note.updated_at) + %cite + = time_ago_in_words(note.updated_at) + ago - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" From 586c53ea0594a327b346c6fed38528a1f508c9e1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 5 Nov 2011 13:59:43 +0200 Subject: [PATCH 12/24] fixed notes loading/paging --- app/assets/javascripts/note.js | 24 ++++++++++++++++++++++- app/controllers/application_controller.rb | 12 ++++++++++++ app/controllers/commits_controller.rb | 5 +---- app/controllers/issues_controller.rb | 5 +---- app/controllers/projects_controller.rb | 5 +---- app/views/notes/_load.js.haml | 11 +++++++++-- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js index 71279fc4..7acc81e5 100644 --- a/app/assets/javascripts/note.js +++ b/app/assets/javascripts/note.js @@ -31,6 +31,15 @@ append: this.initLoadMore(); }, +replace: + function(fid, lid, html) { + this.first_id = fid; + this.last_id = lid; + $("#notes-list").html(html); + this.initLoadMore(); + }, + + prepend: function(id, html) { this.last_id = id; @@ -47,10 +56,23 @@ getNew: dataType: "script"}); }, +refresh: + function() { + // refersh notes list + $.ajax({ + type: "GET", + url: location.href, + data: "first_id=" + this.first_id + "&last_id=" + this.last_id, + dataType: "script"}); + }, + + + initRefresh: function() { // init timer - var int = setInterval("NoteList.getNew()", 20000); + var intNew = setInterval("NoteList.getNew()", 15000); + var intRefresh = setInterval("NoteList.refresh()", 90000); }, initLoadMore: diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 070def96..5c25d7d6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -83,4 +83,16 @@ class ApplicationController < ActionController::Base cookies[:view_style] = "" end end + + def respond_with_notes + if params[:last_id] && params[:first_id] + @notes = @notes.where("id >= ?", params[:first_id]) + elsif params[:last_id] + @notes = @notes.where("id > ?", params[:last_id]) + elsif params[:first_id] + @notes = @notes.where("id < ?", params[:first_id]) + else + nil + end + end end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index f6af56f8..fa0d0b57 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -33,10 +33,7 @@ class CommitsController < ApplicationController respond_to do |format| format.html - format.js do - @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] - @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] - end + format.js { respond_with_notes } end end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b6fd85b8..7ff1ccb3 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -40,10 +40,7 @@ class IssuesController < ApplicationController respond_to do |format| format.html - format.js do - @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] - @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] - end + format.js { respond_with_notes } end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 067245c4..ef7eb921 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -90,10 +90,7 @@ class ProjectsController < ApplicationController respond_to do |format| format.html - format.js do - @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] - @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] - end + format.js { respond_with_notes } end end diff --git a/app/views/notes/_load.js.haml b/app/views/notes/_load.js.haml index f560f0bd..c7ec9ed3 100644 --- a/app/views/notes/_load.js.haml +++ b/app/views/notes/_load.js.haml @@ -1,10 +1,17 @@ - unless @notes.blank? - - if params[:last_id] + - if params[:last_id] && params[:first_id] + :plain + NoteList.replace(#{@notes.last.id}, #{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); + + + - elsif params[:last_id] :plain NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); - - if params[:first_id] + - elsif params[:first_id] :plain NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); + - else + :plain From 5eecbfdb10f97a216b585e7bddcbbd68f71f6ccc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 5 Nov 2011 14:26:06 +0200 Subject: [PATCH 13/24] commit paging fixes --- app/assets/javascripts/commits.js | 48 +++++++++++++++++++++++++ app/controllers/commits_controller.rb | 5 +-- app/views/commits/_commits.html.haml | 1 - app/views/commits/index.html.haml | 12 ++++++- app/views/commits/index.js.erb | 2 -- app/views/commits/index.js.haml | 3 ++ app/views/layouts/application.html.haml | 11 ++---- 7 files changed, 68 insertions(+), 14 deletions(-) delete mode 100644 app/views/commits/index.js.erb create mode 100644 app/views/commits/index.js.haml diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js index a62e9330..bef7ed74 100644 --- a/app/assets/javascripts/commits.js +++ b/app/assets/javascripts/commits.js @@ -7,3 +7,51 @@ $(document).ready(function(){ } }); }); + + + +var CommitsList = { + +ref:null, +limit:0, +offset:0, + +init: + function(ref, limit) { + this.ref=ref; + this.limit=limit; + this.offset=limit; + this.initLoadMore(); + $('.loading').show(); + }, + +getOld: + function() { + $('.loading').show(); + $.ajax({ + type: "GET", + url: location.href, + data: "limit=" + this.limit + "&offset=" + this.offset + "&ref=" + this.ref, + complete: function(){ $('.loading').hide()}, + dataType: "script"}); + }, + +append: + function(count, html) { + $("#commits_list").append(html); + if(count > 0) { + this.offset += count; + this.initLoadMore(); + } + }, + +initLoadMore: + function() { + $(window).bind('scroll', function(){ + if($(window).scrollTop() == $(document).height() - $(window).height()){ + $(window).unbind('scroll'); + CommitsList.getOld(); + } + }); + } +} diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index fa0d0b57..79703cf1 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -13,11 +13,12 @@ class CommitsController < ApplicationController load_refs # load @branch, @tag & @ref @repo = project.repo + limit, offset = (params[:limit] || 20), (params[:offset] || 0) if params[:path] - @commits = @repo.log(@ref, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0) + @commits = @repo.log(@ref, params[:path], :max_count => limit, :skip => offset) else - @commits = @repo.commits(@ref, params[:limit] || 100, params[:offset] || 0) + @commits = @repo.commits(@ref, limit, offset) end respond_to do |format| diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 9761c65f..2d393993 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -22,4 +22,3 @@ %strong= commit.author_name = time_ago_in_words(commit.committed_date) ago -= more_commits_link if @commits.size > 99 diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index b9650145..0dfb2cff 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -15,4 +15,14 @@ .right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) } %div{:id => dom_id(@project)} - = render "commits" + #commits_list= render "commits" +.clear +.loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" + + + +:javascript + $(function(){ + CommitsList.init("#{@ref}", 20); + }); diff --git a/app/views/commits/index.js.erb b/app/views/commits/index.js.erb deleted file mode 100644 index 94daa396..00000000 --- a/app/views/commits/index.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#more-commits-link").remove(); -$('#<%= dom_id(@project)%>').append('<%= escape_javascript(render("commits")) %>'); diff --git a/app/views/commits/index.js.haml b/app/views/commits/index.js.haml new file mode 100644 index 00000000..39b7108c --- /dev/null +++ b/app/views/commits/index.js.haml @@ -0,0 +1,3 @@ +:plain + CommitsList.append(#{@commits.count}, "#{escape_javascript(render(:partial => 'commits/commits'))}"); + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 030f1999..9022ecb1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,11 +2,7 @@ %html %head %title - GitLab #{" - #{@project.name}" if @project && !@project.new_record?} - -#= stylesheet_link_tag 'blueprint/screen', :media => "screen, projection" - -#= stylesheet_link_tag 'blueprint/print', :media => "print" - -#= stylesheet_link_tag 'blueprint/plugins/buttons/screen', :media => "screen, projection" - -#= stylesheet_link_tag 'blueprint/plugins/link-icons/screen', :media => "screen, projection" + GitLab = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags @@ -17,6 +13,5 @@ #container = render :partial => "layouts/flash" = render :partial => "layouts/head_panel" - %div{ :id => "main", :role => "main", :class => "container_4" } - = render :partial => "layouts/page_title" - = yield + = render :partial => "layouts/page_title" + = yield From 31a9d6531dcbfc72babf3da52d17cde61b4bcc04 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 5 Nov 2011 14:45:52 +0200 Subject: [PATCH 14/24] commits notes under diff. tab removed --- app/assets/stylesheets/projects.css.scss | 7 ++++--- app/views/commits/show.html.haml | 24 +++++------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 766138ee..0e1ad931 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -52,7 +52,8 @@ background: #eee; } .diff_file_content { - overflow-x: scroll; + overflow:auto; + overflow-y:hidden; background:#fff; color:#333; font-size: 12px; @@ -174,9 +175,9 @@ a { .old_line, .new_line { background:#ECECEC; color:#777; - width:15px; + width:30px; float:left; - padding: 0px 10px; + padding: 0px 5px; border-right: 1px solid #ccc; } } diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 3bd9145e..b42b23de 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -1,5 +1,5 @@ %h3 - = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}" + = "[ #{@commit.author_name} ] #{truncate(@commit.safe_message, :length => 70)}" -#= link_to 'Back', project_commits_path(@project), :class => "button" %table.round-borders %tr @@ -8,12 +8,9 @@ %tr %td Author %td= @commit.author_name - %tr - %td Commiter - %td= @commit.committer %tr %td Commited Date - %td= @commit.committed_date + %td= @commit.committed_date.stamp("21 Aug 2011, 11:15pm") %tr %td Message %td @@ -24,18 +21,7 @@ %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id) .clear -#tabs - %ul - %li - %a{ :href => "#tabs-1" } Diff - %li - %a{ :href => "#tabs-2" } Comments - %span{ :class => "notes_count" }= @notes.count - %hr - #tabs-1 - = render "commits/diff" - #tabs-2 - = render "notes/notes" +%br -:javascript - $(function() { $( "#tabs" ).tabs(); }); += render "commits/diff" += render "notes/notes" From 1e5aa0effffa60cc5f5a953011cfb40a37b6a862 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sat, 5 Nov 2011 14:57:40 +0200 Subject: [PATCH 15/24] add tags autocomplete --- app/controllers/tags_controller.rb | 15 +++++++++++++ app/views/projects/_form.html.haml | 10 +++++++++ app/views/tags/autocomplete.html.haml | 2 ++ app/views/tags/index.html.haml | 2 ++ config/routes.rb | 3 +++ spec/requests/tags_spec.rb | 31 +++++++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 app/controllers/tags_controller.rb create mode 100644 app/views/tags/autocomplete.html.haml create mode 100644 app/views/tags/index.html.haml create mode 100644 spec/requests/tags_spec.rb diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb new file mode 100644 index 00000000..6ec3226a --- /dev/null +++ b/app/controllers/tags_controller.rb @@ -0,0 +1,15 @@ +class TagsController < ApplicationController + def index + end + + def autocomplete + tags = Project.tag_counts.limit 8 + tags = tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank? + tags = tags.map {|t| t.name} + + respond_to do |format| + format.json { render json: tags} + end + end + +end diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 605a2f45..059ee40c 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -57,9 +57,19 @@ $(function(){ var tag_field = $('#tag_field').tagify(); + + tag_field.tagify('inputField').autocomplete({ + source: '/tags/autocomplete.json', + position: { of: tag_field.tagify('containerDiv') }, + close: function(event, ui) { tag_field.tagify('add'); }, + }); + + $('form').submit( function() { var tag_field = $('#tag_field') tag_field.val( tag_field.tagify('serialize') ); return true; }); + + }) diff --git a/app/views/tags/autocomplete.html.haml b/app/views/tags/autocomplete.html.haml new file mode 100644 index 00000000..e5c86e7e --- /dev/null +++ b/app/views/tags/autocomplete.html.haml @@ -0,0 +1,2 @@ +%h1 Tags#autocomplete +%p Find me in app/views/tags/autocomplete.html.haml \ No newline at end of file diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml new file mode 100644 index 00000000..7bf17b5e --- /dev/null +++ b/app/views/tags/index.html.haml @@ -0,0 +1,2 @@ +%h1 Tags#index +%p Find me in app/views/tags/index.html.haml \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d45c32bd..c6b2d8b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ Gitlab::Application.routes.draw do + get "tags/index" + get "tags/autocomplete" + namespace :admin do resources :users resources :projects diff --git a/spec/requests/tags_spec.rb b/spec/requests/tags_spec.rb new file mode 100644 index 00000000..43d7a0ff --- /dev/null +++ b/spec/requests/tags_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe "Tags" do + before { login_as :user } + + # describe "GET 'tags/index'" do + # it "should be successful" do + # get 'tags/index' + # response.should be_success + # end + # end + + + describe "GET '/tags/autocomplete'" do + before do + @project = Factory :project + @project.add_access(@user, :read) + @project.tag_list = 'demo1' + @project.save + visit '/tags/autocomplete.json' + end + + + it "should contains tags" do + page.should have_content('demo1') + end +end + + + +end From 0499759204449a78ead1950c06fbab4dacfa84f2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 5 Nov 2011 15:31:54 +0200 Subject: [PATCH 16/24] issues & fixed layout --- app/assets/stylesheets/projects.css.scss | 42 +++++------------------ app/controllers/application_controller.rb | 6 ++++ app/views/issues/_show.html.haml | 14 ++++---- app/views/issues/index.html.haml | 10 +++--- app/views/issues/show.html.haml | 23 ++++++------- spec/requests/commits_notes_spec.rb | 1 - 6 files changed, 38 insertions(+), 58 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 0e1ad931..c4b5de8a 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -163,10 +163,6 @@ table.round-borders { padding:20px; } -//body { - //background: #eaeaea; -//} - a { color: #111; } @@ -232,43 +228,15 @@ input.ssh_project_url { text-align:center; } -.day-commits-table li.commit { - cursor:pointer; - - &:hover { - @include hover-color; - } -} - -/* -#FFF6BF -#FFD324 -*/ -#tree-slider tr.tree-item { - cursor:pointer; - - &:hover { - @include hover-color; - td { - @include hover-color; - } - } -} #projects-list .project { height:50px; } +#tree-slider .tree-item, #projects-list .project, #snippets-table .snippet, #issues-table .issue{ cursor:pointer; - - &:hover { - @include hover-color; - td { - @include hover-color; - } - } } .clear { @@ -563,6 +531,7 @@ input.ssh_project_url { @include round-borders-all(4px); padding:2px 4px; border:none; + text-shadow:none; &.high { background: #D12F19; @@ -687,6 +656,13 @@ table.highlighttable pre{ width:200px; } +.issues_filter { + margin-top:10px; + .left { + margin-right:15px; + } +} + body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5c25d7d6..782612c0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -82,6 +82,12 @@ class ApplicationController < ActionController::Base elsif params[:view_style] == "fluid" cookies[:view_style] = "" end + + @view_mode = if cookies[:view_style] == "collapsed" + :fixed + else + :fluid + end end def respond_with_notes diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 94cc03d1..05208d09 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -4,10 +4,11 @@ = image_tag "move.png" , :class => [:handle, :left] %td = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = truncate issue.assignee.name, :lenght => 20 + = issue.assignee.name %td ##{issue.id} %td - = truncate(html_escape(issue.title), :length => 60) + = truncate(html_escape(issue.title), :length => 200) + %br %br - if issue.critical %span.tag.high critical @@ -27,7 +28,8 @@ - else = check_box_tag "closed", 1, issue.closed, :disabled => true %td - - if can?(current_user, :admin_issue, @project) || issue.author == current_user - = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "lbutton positive", :remote => true - - if can?(current_user, :admin_issue, @project) || issue.author == current_user - = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{issue.id}" + - if @view_mode == :fluid + - if can?(current_user, :admin_issue, @project) || issue.author == current_user + = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "lbutton positive", :remote => true + - if can?(current_user, :admin_issue, @project) || issue.author == current_user + = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{issue.id}" diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index a70c65d4..21e455b9 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -7,18 +7,18 @@ = hidden_field_tag :project_id, @project.id, { :id => 'project_id' } = search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' } - .right + .right.issues_filter = form_tag project_issues_path(@project), :method => :get do - .span-2 + .left = radio_button_tag :f, 0, (params[:f] || "0") == "0", :onclick => "this.form.submit()", :id => "open_issues", :class => "status" = label_tag "open_issues","Open" - .span-2 + .left = radio_button_tag :f, 2, params[:f] == "2", :onclick => "this.form.submit()", :id => "closed_issues", :class => "status" = label_tag "closed_issues","Closed" - .span-2 + .left = radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues", :class => "status" = label_tag "my_issues","To Me" - .span-2 + .left = radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues", :class => "status" = label_tag "all_issues","All" diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 8267a850..dc4ab338 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,5 +1,9 @@ %h2 - = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" + %strong + Issue + = "##{@issue.id}" + – + = html_escape(@issue.title) .left.width-65p .issue_notes= render "notes/notes" @@ -8,14 +12,6 @@ .right.width-30p .span-8 %table.round-borders - %tr - %td Title: - %td - = truncate html_escape(@issue.title) - %tr - %td Project - %td - %strong= @issue.project.name %tr %td Author: %td @@ -39,7 +35,7 @@ %tr %td Closed? %td - - if can? current_user, :write_issue, @project + - if can? current_user, :write_issue, @issue = form_for([@project, @issue]) do |f| = f.check_box :closed, :onclick => "$(this).parent().submit();" = hidden_field_tag :status_only, true @@ -47,8 +43,9 @@ = check_box_tag "closed", 1, @issue.closed, :disabled => true - - if can?(current_user, :admin_issue, @issue) + - if can?(current_user, :write_issue, @issue) .clear - = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true - .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" + %br + = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true + .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .clear diff --git a/spec/requests/commits_notes_spec.rb b/spec/requests/commits_notes_spec.rb index c424f4fc..69a492e9 100644 --- a/spec/requests/commits_notes_spec.rb +++ b/spec/requests/commits_notes_spec.rb @@ -12,7 +12,6 @@ describe "Issues" do describe "add new note", :js => true do before do visit project_commit_path(project, commit) - click_link "Comments" # notes tab fill_in "note_note", :with => "I commented this commit" click_button "Add note" end From 6e08b5cc857b3b218df0b20745ad295e79abc722 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sat, 5 Nov 2011 21:00:05 +0200 Subject: [PATCH 17/24] create tags page and made tag filter for projects --- app/assets/stylesheets/projects.css.scss | 14 ++++++++++++++ app/assets/stylesheets/tags.css.css | 16 ++++++++++++++++ app/controllers/projects_controller.rb | 4 +++- app/controllers/tags_controller.rb | 12 ++++-------- app/views/projects/_form.html.haml | 7 +------ app/views/projects/_list.html.haml | 7 ++++++- app/views/tags/autocomplete.html.haml | 2 -- app/views/tags/index.html.haml | 13 +++++++++++-- config/routes.rb | 7 +++++-- spec/requests/tags_spec.rb | 4 ++-- 10 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 app/assets/stylesheets/tags.css.css delete mode 100644 app/views/tags/autocomplete.html.haml diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 766138ee..c6ba8b46 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -270,6 +270,20 @@ input.ssh_project_url { } } +#projects-list .small-tags a{ + font-size: 9px; + + display: inline-block; + padding: 2px 3px 1px 3px; + margin: 0px 3px 0px 0px; + border-radius: 2px; + background-color: #3b6bce; + color: #FFF; + text-shadow: none; + font-weight: bold; +} + + .clear { clear: both; } diff --git a/app/assets/stylesheets/tags.css.css b/app/assets/stylesheets/tags.css.css new file mode 100644 index 00000000..0dfcc4fc --- /dev/null +++ b/app/assets/stylesheets/tags.css.css @@ -0,0 +1,16 @@ +.tags-list { + padding : 0px 10px 10px 10px; + +} + +.tags-list a { + display: inline-block; + padding: 8px 11px 8px 11px; + margin: 1px 5px 0px 0px; + border-radius: 4px; + border: 1px solid #d0e1ff; + background-color: #d0e1ff; + color: #0f326d; + font-weight: bold; + font-size: 14px; +} \ No newline at end of file diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 067245c4..09661685 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -10,7 +10,9 @@ class ProjectsController < ApplicationController before_filter :require_non_empty_project, :only => [:blob, :tree] def index - @projects = current_user.projects.all + source = current_user.projects + source = source.tagged_with(params[:tag]) unless params[:tag].blank? + @projects = source.all end def new diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6ec3226a..913bc62b 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,15 +1,11 @@ class TagsController < ApplicationController def index - end - - def autocomplete - tags = Project.tag_counts.limit 8 - tags = tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank? - tags = tags.map {|t| t.name} + @tags = Project.tag_counts.order('count DESC') + @tags = @tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank? respond_to do |format| - format.json { render json: tags} + format.html + format.json { render json: @tags.limit(8).map {|t| t.name}} end end - end diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 059ee40c..2ddfda48 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -57,11 +57,8 @@ $(function(){ var tag_field = $('#tag_field').tagify(); - tag_field.tagify('inputField').autocomplete({ - source: '/tags/autocomplete.json', - position: { of: tag_field.tagify('containerDiv') }, - close: function(event, ui) { tag_field.tagify('add'); }, + source: '/tags.json' }); @@ -70,6 +67,4 @@ tag_field.val( tag_field.tagify('serialize') ); return true; }); - - }) diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml index 65f0b7fd..7976b11f 100644 --- a/app/views/projects/_list.html.haml +++ b/app/views/projects/_list.html.haml @@ -10,7 +10,12 @@ - @projects.each do |project| %tr{ :class => "project", :url => project_path(project) } - %td= project.name + %td + = project.name + .small-tags + - project.tag_list.each do |tag| + = link_to tag, "/tags/#{tag}" + %td= truncate project.url_to_repo %td= project.code %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled diff --git a/app/views/tags/autocomplete.html.haml b/app/views/tags/autocomplete.html.haml deleted file mode 100644 index e5c86e7e..00000000 --- a/app/views/tags/autocomplete.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%h1 Tags#autocomplete -%p Find me in app/views/tags/autocomplete.html.haml \ No newline at end of file diff --git a/app/views/tags/index.html.haml b/app/views/tags/index.html.haml index 7bf17b5e..c83d62c7 100644 --- a/app/views/tags/index.html.haml +++ b/app/views/tags/index.html.haml @@ -1,2 +1,11 @@ -%h1 Tags#index -%p Find me in app/views/tags/index.html.haml \ No newline at end of file +- content_for(:body_class, "projects-page") +- content_for(:page_title) do + .grid_4 + %h2 + Tags + + + .tags-list + - @tags.all.each do |tag| + = link_to "#{tag.name}(#{tag.count})", "/tags/#{tag.name}" + diff --git a/config/routes.rb b/config/routes.rb index c6b2d8b1..d4e27965 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,8 @@ Gitlab::Application.routes.draw do - get "tags/index" - get "tags/autocomplete" + + get 'tags'=> 'tags#index' + get 'tags/:tag' => 'projects#index' + namespace :admin do resources :users @@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do resources :projects, :only => [:new, :create, :index] resources :keys + devise_for :users resources :projects, :except => [:new, :create, :index], :path => "/" do diff --git a/spec/requests/tags_spec.rb b/spec/requests/tags_spec.rb index 43d7a0ff..94a034da 100644 --- a/spec/requests/tags_spec.rb +++ b/spec/requests/tags_spec.rb @@ -11,13 +11,13 @@ describe "Tags" do # end - describe "GET '/tags/autocomplete'" do + describe "GET '/tags.json'" do before do @project = Factory :project @project.add_access(@user, :read) @project.tag_list = 'demo1' @project.save - visit '/tags/autocomplete.json' + visit '/tags.json' end From 62112dc0c7eae8d8c8e3d55fc13d3d58b7588899 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sat, 5 Nov 2011 22:16:13 +0200 Subject: [PATCH 18/24] add tags to project list --- app/assets/stylesheets/projects.css.scss | 14 -------------- app/assets/stylesheets/tags.css.css | 18 ++++++++++++++++-- app/views/projects/_tile.html.haml | 5 +++++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index c6ba8b46..766138ee 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -270,20 +270,6 @@ input.ssh_project_url { } } -#projects-list .small-tags a{ - font-size: 9px; - - display: inline-block; - padding: 2px 3px 1px 3px; - margin: 0px 3px 0px 0px; - border-radius: 2px; - background-color: #3b6bce; - color: #FFF; - text-shadow: none; - font-weight: bold; -} - - .clear { clear: both; } diff --git a/app/assets/stylesheets/tags.css.css b/app/assets/stylesheets/tags.css.css index 0dfcc4fc..afd458fd 100644 --- a/app/assets/stylesheets/tags.css.css +++ b/app/assets/stylesheets/tags.css.css @@ -8,9 +8,23 @@ padding: 8px 11px 8px 11px; margin: 1px 5px 0px 0px; border-radius: 4px; - border: 1px solid #d0e1ff; - background-color: #d0e1ff; + border: 1px solid #72bbdf; + background-color: #72bbdf; color: #0f326d; font-weight: bold; font-size: 14px; +} + + +.small-tags a{ + font-size: 9px; + + display: inline-block; + padding: 2px 3px 1px 3px; + margin: 0px 3px 0px 0px; + border-radius: 2px; + background-color: #72bbdf; + color: #FFF; + text-shadow: none; + font-weight: bold; } \ No newline at end of file diff --git a/app/views/projects/_tile.html.haml b/app/views/projects/_tile.html.haml index 7c0b8679..cc891f63 100644 --- a/app/views/projects/_tile.html.haml +++ b/app/views/projects/_tile.html.haml @@ -12,6 +12,11 @@ %span Last Activity: - last_note = project.notes.last = last_note ? last_note.created_at.stamp("24 Aug, 2011") : "Never" + + %p.small-tags + - project.tag_list.each do |tag| + = link_to tag, "/tags/#{tag}" + .buttons %a.browse-code.button.yellow{:href => tree_project_path(project)} Browse code %a.commits.button.green{:href => project_commits_path(project)} Commits From 671e261e900491ae29e118ac12f3ca9328109ab8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 15:52:23 +0200 Subject: [PATCH 19/24] lil design changes --- app/assets/stylesheets/projects.css.scss | 4 ++++ app/views/issues/_issues.html.haml | 1 - app/views/issues/_show.html.haml | 14 ++++++++------ app/views/notes/_show.html.haml | 10 +++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index c4b5de8a..c31f795a 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -663,6 +663,10 @@ table.highlighttable pre{ } } +.cgray { color:gray; } +.cred { color:#D12F19; } +.cgreen { color:#44aa22; } + body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index a6a38e69..d758fed5 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -6,7 +6,6 @@ %th ID %th Title %th Closed? - %th - @issues.critical.each do |issue| = render(:partial => 'show', :locals => {:issue => issue}) diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 05208d09..72b99b04 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -14,6 +14,14 @@ %span.tag.high critical - if issue.today? %span.tag.today today + + .right + - if can?(current_user, :admin_issue, @project) || issue.author == current_user + = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "cgray", :remote => true + - if can?(current_user, :admin_issue, @project) || issue.author == current_user +   + = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-issue negative", :id => "destroy_issue_#{issue.id}" + -#- if issue.author == current_user -#%span.tag.yours yours -#- if issue.notes.count > 0 @@ -27,9 +35,3 @@ = hidden_field_tag :status_only, true - else = check_box_tag "closed", 1, issue.closed, :disabled => true - %td - - if @view_mode == :fluid - - if can?(current_user, :admin_issue, @project) || issue.author == current_user - = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "lbutton positive", :remote => true - - if can?(current_user, :admin_issue, @project) || issue.author == current_user - = link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{issue.id}" diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index 5d766291..27cb3874 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -2,16 +2,16 @@ = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" %div.note-author %strong= note.author_name - %cite + %cite.cgray = time_ago_in_words(note.updated_at) ago - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) - = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" + = link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note right" %div.note-title = markdown(note.note) - if note.attachment.url - Attachment: - = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" - %br + .right + %span.file + = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" .clear From 526752479d7a85596259fdee6f55cdefbbc3c1d6 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sun, 6 Nov 2011 20:48:21 +0200 Subject: [PATCH 20/24] correct html on project page --- app/views/projects/index.html.haml | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index a35ead82..ba860571 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -1,18 +1,20 @@ - content_for(:body_class, "projects-page") - content_for(:page_title) do - .grid_4 - - if current_user.can_create_project? - %a.grey-button.right{:href => new_project_path} Create new project - %h2.icon - %span - Projects + .container_4 + .grid_4 + - if current_user.can_create_project? + %a.grey-button.right{:href => new_project_path} Create new project + %h2.icon + %span + Projects -- unless @projects.empty? - %div{:class => "tile", :style => view_mode_style("tile")} - = render "tile" - %div{:class => "list", :style => view_mode_style("list")} - = render "list" -- else - %center.prepend-top - %h2 - %cite Nothing here + %div.clear + - unless @projects.empty? + %div{:class => "tile", :style => view_mode_style("tile")} + = render "tile" + %div{:class => "list", :style => view_mode_style("list")} + = render "list" + - else + %center.prepend-top + %h2 + %cite Nothing here From 1d1b5186c3cbf85fb8f539b241ced29c314a3ff2 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sun, 6 Nov 2011 21:43:34 +0200 Subject: [PATCH 21/24] fix small bug in top menu (buttons change height on press in chrome) --- app/assets/stylesheets/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/style.scss b/app/assets/stylesheets/style.scss index 29e6058d..ec403eba 100755 --- a/app/assets/stylesheets/style.scss +++ b/app/assets/stylesheets/style.scss @@ -323,6 +323,7 @@ header nav{border-radius: 4px; box-shadow: 0 1px 2px black; width: 294px; margin background-image: -moz-linear-gradient(#595d63 6.6%, #31363e); background-image: -o-linear-gradient(#595d63 6.6%, #31363e); margin-top: 2px; + height:30px } header nav a{padding: 8px 12px 8px 34px; display: inline-block; color: #D6DADF; border-right: 1px solid #31363E; position: relative; box-shadow: 1px 0 0 rgba(255,255,255,.1); margin: 0} header nav a span{width: 20px; height: 20px; display: inline-block; background: red; position: absolute; left: 8px; top: 6px;} From f87f0201f0e3386d1e0408a217650b545f57029a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:21:48 +0200 Subject: [PATCH 22/24] link to author on tree view item --- app/assets/stylesheets/projects.css.scss | 9 +++++++++ app/helpers/application_helper.rb | 4 ++++ app/views/commits/_commits.html.haml | 2 +- app/views/projects/_tree_item.html.haml | 7 +++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index c31f795a..7dfd8b29 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -667,6 +667,15 @@ table.highlighttable pre{ .cred { color:#D12F19; } .cgreen { color:#44aa22; } +body.project-page table .commit { + a.tree-commit-link { + color:gray; + &:hover { + text-decoration:underline; + } + } +} + body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note img{float: left; margin-right: 10px;} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70984804..70047c41 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,6 +4,10 @@ module ApplicationHelper "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" end + def fixed_mode? + @view_mode == :fixed + end + def body_class(default_class = nil) main = content_for(:body_class).blank? ? default_class : diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 2d393993..f47252ab 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -17,7 +17,7 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %span.commit-title %strong - = truncate(commit.safe_message, :length => 60) + = truncate(commit.safe_message, :length => fixed_mode? ? 60 : 120) %span.commit-author %strong= commit.author_name = time_ago_in_words(commit.committed_date) diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index 53c05d5a..d15c379b 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -11,5 +11,8 @@ %td = time_ago_in_words(content_commit.committed_date) ago - %td - = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit) + %td.commit + = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link" + - user = @project.users.find_by_email(content_commit.author_email) + - if user + = link_to "[#{user.name}]", project_team_member_path(@project, @project.users_projects.find_by_user_id(user.id)) From b4868a897284940a3e5e8e6ebcc246f21fb17fbe Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:38:08 +0200 Subject: [PATCH 23/24] Improved commit author detection --- app/models/project.rb | 5 +++++ app/views/projects/_tree_item.html.haml | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index de68f451..a5b6224b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -50,6 +50,11 @@ class Project < ActiveRecord::Base code end + def team_member_by_name_or_email(email = nil, name = nil) + user = users.where("email like ? or name like ?", email, name).first + users_projects.find_by_user_id(user.id) if user + end + def common_notes notes.where(:noteable_type => ["", nil]) end diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index d15c379b..273d0272 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -13,6 +13,6 @@ ago %td.commit = link_to truncate(content_commit.safe_message, :length => fixed_mode? ? 40 : 80), project_commit_path(@project, content_commit), :class => "tree-commit-link" - - user = @project.users.find_by_email(content_commit.author_email) - - if user - = link_to "[#{user.name}]", project_team_member_path(@project, @project.users_projects.find_by_user_id(user.id)) + - tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name) + - if tm + = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm) From e29a25662dac63c2f1ef0041eeb7b6fd24d3896e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 6 Nov 2011 22:53:36 +0200 Subject: [PATCH 24/24] fixed 1click repo url selection --- app/views/layouts/project.html.haml | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index ee6581ec..984ff4d0 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -16,29 +16,29 @@ .project-container .project-sidebar .fixed - %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo} - %aside - = link_to "History", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil - = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil - = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil - = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do - Team - - if @project.users_projects.count > 0 - %span{ :class => "number" }= @project.users_projects.count - = link_to project_issues_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do - Issues - - if @project.issues.opened.count > 0 - %span{ :class => "number" }= @project.issues.opened.count - = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do - Wall - - if @project.common_notes.count > 0 - %span{ :class => "number" }= @project.common_notes.count - = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do - Snippets - - if @project.snippets.count > 0 - %span{ :class => "number" }= @project.snippets.non_expired.count - - if @commit - = link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil + %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} + %aside + = link_to "History", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil + = link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil + = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil + = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do + Team + - if @project.users_projects.count > 0 + %span{ :class => "number" }= @project.users_projects.count + = link_to project_issues_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do + Issues + - if @project.issues.opened.count > 0 + %span{ :class => "number" }= @project.issues.opened.count + = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do + Wall + - if @project.common_notes.count > 0 + %span{ :class => "number" }= @project.common_notes.count + = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do + Snippets + - if @project.snippets.count > 0 + %span{ :class => "number" }= @project.snippets.non_expired.count + - if @commit + = link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil .project-content = yield