[issue #203] Some layout changes & presenters.
* Fixed bugs in layout * Fixed typos * Fixed bugs in JS * Added universal partial _feed_message.html.haml * Added presenters * Added CommitAsMessage presenter, that prepares Grit::Commit to be shown as message.
This commit is contained in:
parent
608faf3564
commit
edc8774387
|
@ -25,6 +25,14 @@ $(document).ready(function(){
|
|||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('.data-expander').live('click', function(e) {
|
||||
var $button = $(e.target);
|
||||
var id = "#content-" + $button.attr('id');
|
||||
var $slider = $(id);
|
||||
$slider.slideToggle("slow", function(){
|
||||
$button.toggleClass('expanded collapsed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).click(function(e) {
|
||||
|
@ -36,9 +44,9 @@ $(document).click(function(e) {
|
|||
function showActivity(elem) {
|
||||
$("#activity-bottom"+elem).slideToggle("slow");
|
||||
var img = $("#expand" + elem).attr("src");
|
||||
if (img == "assets/expand-gray.png") {
|
||||
$("#expand" + elem).attr("src","assets/expand-gray2.png");
|
||||
if (img == "/assets/expand-gray.png") {
|
||||
$("#expand" + elem).attr("src","/assets/expand-gray2.png");
|
||||
} else {
|
||||
$("#expand" + elem).attr("src","assets/expand-gray.png");
|
||||
$("#expand" + elem).attr("src","/assets/expand-gray.png");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
jQuery(document).ready(function(){
|
||||
|
||||
var params = {
|
||||
changedEl: ".lineForm select",
|
||||
visRows: 999999,
|
||||
scrollArrows: false
|
||||
}
|
||||
|
||||
cuSel(params);
|
||||
//var params = {
|
||||
// changedEl: ".lineForm select",
|
||||
// visRows: 999999,
|
||||
// scrollArrows: false
|
||||
// }
|
||||
//
|
||||
// cuSel(params);
|
||||
|
||||
});
|
|
@ -12,3 +12,76 @@ header menu ul li a {
|
|||
padding: 15px 8px 15px 8px;
|
||||
}
|
||||
|
||||
div.description-top div.name {
|
||||
width: 300px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.description-top div.name input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
article div.activity {
|
||||
border: 1px solid #D6D6D6;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
color: #333333;
|
||||
margin-top: 15px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
article div.activity .top div.image {
|
||||
position: absolute;
|
||||
float: left;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-left: 2px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
article div.activity .top div.text {
|
||||
float: left;
|
||||
font-size: 12px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
article div.activity .top div.text.imaged {
|
||||
margin-left: 44px;
|
||||
}
|
||||
|
||||
article div.activity .top div.text .name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
article div.activity .top div.text .date {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
article div.activity .top div.text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
article div.activity .fulltext {
|
||||
font-size: 12px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
article div.activity .fulltext.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.activity .data-expander {
|
||||
margin-left: 10px;
|
||||
display: inline-block;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
div.activity .data-expander.collapsed {
|
||||
background: #FFF image-url('expand-gray.png') no-repeat;
|
||||
background-position: 0 2px;
|
||||
}
|
||||
|
||||
div.activity .data-expander.expanded {
|
||||
background: #FFF image-url('expand-gray2.png') no-repeat;
|
||||
background-position: 0 2px;
|
||||
}
|
||||
|
|
|
@ -1220,7 +1220,7 @@ h3.bmargin10 {
|
|||
padding-top: 9px;
|
||||
}
|
||||
|
||||
div.desription-top {
|
||||
div.description-top {
|
||||
background: #dcecfa;
|
||||
font-size: 12px;
|
||||
color: #575756;
|
||||
|
@ -1230,13 +1230,13 @@ div.desription-top {
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
div.desription-top div.img {
|
||||
div.description-top div.img {
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
div.desription-top div.name {
|
||||
div.description-top div.name {
|
||||
float: left;
|
||||
margin-top: 5px;
|
||||
margin-left: 10px;
|
||||
|
@ -1250,19 +1250,19 @@ div.desription-top div.name {
|
|||
padding-top: 5px;
|
||||
}
|
||||
|
||||
div.desription-top div.role {
|
||||
div.description-top div.role {
|
||||
float: left;
|
||||
margin-top: 11px;
|
||||
margin-left: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
div.desription-top div.fork {
|
||||
div.description-top div.fork {
|
||||
float: right;
|
||||
margin-top: 5px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
div.desription-top div.fork p {
|
||||
div.description-top div.fork p {
|
||||
float: right;
|
||||
margin-top: 5px;
|
||||
margin-right: 2px;
|
||||
|
|
|
@ -84,6 +84,18 @@ class Project < ActiveRecord::Base
|
|||
self.git_repository.branches
|
||||
end
|
||||
|
||||
def last_active_branch
|
||||
@last_active_branch ||= branches.inject do |r, c|
|
||||
r_last = r.commit.committed_date || r.commit.authored_date unless r.nil?
|
||||
c_last = c.commit.committed_date || c.commit.authored_date
|
||||
if r.nil? or r_last < c_last
|
||||
r = c
|
||||
end
|
||||
r
|
||||
end
|
||||
@last_active_branch
|
||||
end
|
||||
|
||||
def versions
|
||||
tags.map(&:name) + branches.map{|b| "latest_#{b.name}"}
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
class ApplicationPresenter
|
||||
include Rails.application.routes.url_helpers
|
||||
include ActionView::Helpers::UrlHelper
|
||||
|
||||
def initialize(*args)
|
||||
end
|
||||
|
||||
# TODO it needs to be refactored!
|
||||
class << self
|
||||
def present(*args, &block)
|
||||
block.call(self.new(*args))
|
||||
end
|
||||
|
||||
def present_collection(collection, &block)
|
||||
res = collection.map {|e| self.new(*e)}
|
||||
if block.present?
|
||||
res = res.inject('') do |akk, presenter|
|
||||
akk << block.call(presenter)
|
||||
akk
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
|
||||
attr_accessor :commit, :options
|
||||
attr_reader :header, :image, :date, :caption, :content, :expandable
|
||||
|
||||
def initialize(commit, opts = {})
|
||||
@commit = commit
|
||||
@optons = opts#[:branch] if opts[:branch]
|
||||
prepare_message
|
||||
end
|
||||
|
||||
def header
|
||||
@header ||= if options[:branch].present?
|
||||
I18n.t("layout.messages.commits.header_with_branch",
|
||||
:committer => committer_link, :commit => '', :branch => options[:branch].name)
|
||||
elsif options[:project].present?
|
||||
I18n.t("layout.messages.commits.header_with_project",
|
||||
:committer => committer_link, :commit => '', :project => options[:project].name)
|
||||
end.html_safe
|
||||
end
|
||||
|
||||
def image
|
||||
@image ||= "https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(committer.email.downcase)}?s=40&r=pg"
|
||||
end
|
||||
|
||||
def date
|
||||
@date ||= I18n.l(@commit.committed_date || @commit.authored_date, :format => :long)
|
||||
end
|
||||
|
||||
def expandable?
|
||||
true
|
||||
end
|
||||
|
||||
def content?
|
||||
!content.blank?
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def committer
|
||||
@committer ||= User.where(:email => @commit.committer.email).first || @commit.committer
|
||||
end
|
||||
|
||||
def committer_link
|
||||
@committer_link ||= if committer.is_a? User
|
||||
link_to committer.uname, user_path(c)
|
||||
else
|
||||
mail_to committer.email, committer.name
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_message
|
||||
(@caption, @content) = @commit.message.split("\n\n", 2)
|
||||
if @caption.length > 72
|
||||
@content = '...' + @caption[69..-1] + @content
|
||||
@caption = @caption[0..68] + '...'
|
||||
end
|
||||
@content = @content.gsub("\n", "<br />").html_safe
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@
|
|||
= csrf_meta_tag
|
||||
|
||||
%body
|
||||
.wrap
|
||||
.wrap{:class => content_for?(:sidebar) ? 'columns' : ''}
|
||||
%header
|
||||
.left
|
||||
.middle
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
.block
|
||||
= render :partial => 'submenu'
|
||||
= render :partial => 'repo_block', :locals => {:project => @project}
|
||||
|
||||
.description
|
||||
%h3= t("layout.projects.about_subheader")
|
||||
%p
|
||||
= @project.description
|
||||
= link_to t('layout.read_more'), '#'
|
||||
|
||||
%h3= t("layout.projects.last_commit")
|
||||
- GitPresenters::CommitAsMessagePresenter.present(@project.last_active_branch.commit,
|
||||
:branch => @project.last_active_branch) do |presenter|
|
||||
= render :partial => 'shared/feed_message', :locals => {:presenter => presenter,
|
||||
:item_no => 1}
|
||||
|
||||
-#.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.projects.list"), projects_path
|
||||
|
@ -38,8 +53,8 @@
|
|||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_path(@project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete") if can? :destroy, @project
|
||||
= link_to "Fork", fork_project_path(@project), :class => "button", :method => "post", :confirm => t("layout.confirm") if can? :fork, @project
|
||||
|
||||
%a{ :name => "build_lists"}
|
||||
.block
|
||||
-#%a{ :name => "build_lists"}
|
||||
-#.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists"
|
||||
|
@ -48,4 +63,4 @@
|
|||
.content
|
||||
= render :partial => "build_lists/build_lists", :object => @current_build_lists
|
||||
|
||||
- content_for :sidebar, render('sidebar')
|
||||
-# content_for :sidebar, render('sidebar')
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
.activity
|
||||
.top
|
||||
.image
|
||||
%img{:alt => "avatar", :src => presenter.image}
|
||||
.text.imaged
|
||||
%span.name= presenter.header
|
||||
%br/
|
||||
%span.date= presenter.date
|
||||
%br/
|
||||
%span.subject
|
||||
= presenter.caption
|
||||
- if presenter.expandable? and presenter.content?
|
||||
%span.data-expander.collapsed{:id => "expand#{item_no}"}
|
||||
-#%img#expand1.activity-full{:alt => "expand", :onclick => "showActivity(4)", :src => "/assets/expand-gray.png"}/
|
||||
.both
|
||||
- if presenter.content?
|
||||
.fulltext{:class => presenter.expandable? ? "hidden" : '',
|
||||
:id => presenter.expandable? ? "content-expand#{item_no}" : ''}
|
||||
= presenter.content
|
|
@ -24,6 +24,7 @@ module Rosa
|
|||
|
||||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
# config.autoload_paths += %W(#{config.root}/extras)
|
||||
config.autoload_paths += %W(#{config.root}/app/presenters)
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
|
@ -38,6 +39,7 @@ module Rosa
|
|||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
|
||||
config.i18n.default_locale = :en
|
||||
|
||||
config.action_view.javascript_expansions[:defaults] = %w()
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
ru:
|
||||
layout:
|
||||
messages:
|
||||
commits:
|
||||
header_with_branch: "%{committer} добавил коммит %{commit} в ветку %{branch}"
|
Loading…
Reference in New Issue