Commit 4d89322d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Snippets - fixed after bootstrap

Project - restyled show page, removed info page
Repository - restyled show page, added download option
Tags - added download options
parent 3d77183c
var Pager = {
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,
complete: function(){ $('.loading').hide()},
dataType: "script"});
},
append:
function(count, html) {
$(".content_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');
Pager.getOld();
}
});
}
}
......@@ -97,7 +97,7 @@ $blue_link: "#2fa0bb";
min-width:$min_app_width;
max-width:$max_app_width;
margin:auto;
margin-top:51px;
margin-top:52px;
}
.container-fluid > .sidebar {
......@@ -113,7 +113,7 @@ $blue_link: "#2fa0bb";
aside a {
display:block;
position:relative;
padding:15px 10px;
padding:12px 10px;
margin:10px 0 0 0;
font-size:13px;
font-weight:bold;
......@@ -169,6 +169,7 @@ img.lil_av {
p { padding-top:5px;}
}
.visible_link,
.author_link {
color: $active_link_color;
}
......
......@@ -17,6 +17,7 @@ td.code,
td.linenos{
padding:0;
margin:0;
border-top:0;
vertical-align:top;
}
......
......@@ -191,3 +191,13 @@ a.project-update.titled {
}
}
input.git_clone_url {
width:475px;
}
.team_member_row {
img {
width:60px;
}
}
......@@ -3,7 +3,7 @@ body header {
width:100%;
padding:0;
margin:0;
top:0;
top:1px;
left:0;
background: #F1F1F1; /* for non-css3 browsers */
border-bottom: 1px solid #ccc;
......@@ -23,12 +23,13 @@ body header {
.project_name {
float:left;
width:235px;
width:400px;
margin-right:30px;
font-size:16px;
font-weight:bold;
padding:8px;
color:#333;
text-shadow: 0 1px 1px #FFF;
}
.git_url_wrapper {
......
......@@ -57,7 +57,7 @@ class ProjectsController < ApplicationController
def update
respond_to do |format|
if project.update_attributes(params[:project])
format.html { redirect_to info_project_path(project), :notice => 'Project was successfully updated.' }
format.html { redirect_to edit_project_path(project), :notice => 'Project was successfully updated.' }
format.js
else
format.html { render action: "edit" }
......@@ -69,17 +69,13 @@ class ProjectsController < ApplicationController
def show
return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
limit = (params[:limit] || 10).to_i
@activities = @project.activities(limit)#updates_wo_repo(limit)
@activities = @project.activities(limit)
end
def files
@notes = @project.notes.where("attachment != 'NULL'").order("created_at DESC").limit(100)
end
def info
end
#
# Wall
#
......
......@@ -19,4 +19,28 @@ class RepositoriesController < ApplicationController
def tags
@tags = @project.repo.tags.sort_by(&:name).reverse
end
def archive
unless can?(current_user, :download_code, @project)
render_404 and return
end
ref = params[:ref] || @project.root_ref
commit = @project.commit(ref)
render_404 and return unless commit
# Build file path
file_name = @project.code + "-" + commit.id.to_s + ".tar.gz"
storage_path = File.join(Rails.root, "tmp", "repositories", @project.code)
file_path = File.join(storage_path, file_name)
# Create file if not exists
unless File.exists?(file_path)
FileUtils.mkdir_p storage_path
file = @project.repo.archive_to_file(ref, nil, file_path)
end
# Send file to user
send_file file_path
end
end
......@@ -59,6 +59,7 @@ class SnippetsController < ApplicationController
@snippet = @project.snippets.find(params[:id])
@notes = @snippet.notes
@note = @project.notes.new(:noteable => @snippet)
render_full_content
end
def destroy
......
......@@ -17,7 +17,7 @@ module ProjectsHelper
end
def project_tab_class
[:show, :files, :team, :edit, :update, :info].each do |action|
[:show, :files, :team, :edit, :update].each do |action|
return "current" if current_page?(:controller => "projects", :action => action, :id => @project)
end
......
......@@ -40,6 +40,10 @@ class Ability
:admin_note
] if project.allow_admin_for?(user)
rules << [
:download_code,
] if project.allow_pull_for?(user)
rules.flatten
end
......
......@@ -233,6 +233,10 @@ class Project < ActiveRecord::Base
!users_projects.where(:user_id => user.id, :project_access => [PROJECT_RWA]).empty? || owner_id == user.id
end
def allow_pull_for?(user)
!users_projects.where(:user_id => user.id, :repo_access => [Repository::REPO_R, Repository::REPO_RW]).empty?
end
def root_ref
default_branch || "master"
end
......
%li.entry
= link_to project_commit_path(@project, :id => commit.id) do
%div
%strong
= truncate commit.id.to_s, :length => 10
%code= commit.id.to_s[0..10]
&ndash;
= image_tag gravatar_icon(commit.author_email), :class => "", :width => 16
= truncate(commit.safe_message, :length => 50)
......
= form_tag project_commits_path(@project), :method => :get do
%h3
= @project.name
[ #{select_tag "branch", options_for_select(@repo.heads.map(&:name), @branch), :onchange => "this.form.submit();", :class => "small"} ]
= link_to 'Back', project_path(@project), :class => "button"
%h1 Listing commits
%div{:id => dom_id(@project)}
= render "commits"
%br/
.commit
%span.commit-info
= link_to tree_project_ref_path(@project, @commit.id), :class => "btn right" do
Browse Code »
- if @commit.author_email
= image_tag gravatar_icon(@commit.author_email), :class => "left", :width => 40, :style => "padding-right:5px;"
- else
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
%span.commit-title
%strong
= truncate(@commit.id.to_s, :length => 60)
%span.commit-author
%strong= @commit.author_name
= @commit.created_at.stamp("Aug 21, 2011 9:23pm")
= link_to tree_project_ref_path(@project, @commit.id), :class => "btn right small" do
Browse Code »
= image_tag gravatar_icon(@commit.author_email), :class => "avatar"
%code= @commit.id.to_s
%h5
= @commit.author_name
%small= @commit.created_at.stamp("Aug 21, 2011 9:23pm")
%hr
%pre.commit_message
......
......@@ -8,9 +8,7 @@
- if project_layout
.project_name
= truncate @project.name, :length => 28
.git_url_wrapper
%input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
= truncate @project.name, :length => 35
.account-box
......
......@@ -6,8 +6,12 @@
- if @project.repo_exists?
= link_to "Repository", project_repository_path(@project), :class => repository_tab_class
= link_to "Code", tree_project_ref_path(@project, @project.root_ref), :class => tree_tab_class
= link_to "Commits", project_commits_path(@project), :class => (controller.controller_name == "commits") ? "current" : nil
%ul
%li
= link_to "Code", tree_project_ref_path(@project, @project.root_ref), :class => tree_tab_class
%li
= link_to "Commits", project_commits_path(@project), :class => (controller.controller_name == "commits") ? "current" : nil
= link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
- if @project.issues_enabled
= link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do
......
%li.wll
.row
.span9
= image_tag gravatar_icon(update.author_email), :class => "avatar thumb"
%p
%strong.author= update.author_name
%span
- @activities.each do |update|
.entry
= link_to dashboard_feed_path(@project, update) do
- if update.kind_of? Note
%p
%strong
- if update.target
= update.target.class.name.titleize
= truncate update.target.id.to_s, :length => 10
commented
- else
Project wall
&ndash;
authored
= time_ago_in_words(update.created_at)
ago
- if update.kind_of? MergeRequest
= link_to project_merge_request_path(@project, update) do
= "Opened merge request ##{update.id}."
%span.label= update.source_branch
&rarr;
%span.label= update.target_branch
- elsif update.kind_of? Issue
= link_to project_issue_path(@project, update) do
Opened new
%span.label.important= "issue ##{update.id}"
= truncate update.title
= image_tag gravatar_icon(update.author_email), :class => "", :width => 16
= truncate dashboard_feed_title(update), :length => 50
- else
= link_to [@project, update.target] do
%p
= update.target.class.name.titleize
= truncate(update.target.id.to_s, :length => 10)
&nbsp;
= dashboard_feed_title(update)
%p
%strong
= update.class.name.titleize
= truncate update.id.to_s
&ndash;
= image_tag gravatar_icon(update.author_email), :class => "", :width => 16
= truncate dashboard_feed_title(update), :length => 50
......@@ -10,13 +10,17 @@
.clearfix
= f.label :path do
Path
%cite= "git@#{GIT_HOST["host"]}:"
.input= f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record?
.input
.input-prepend
%span.add-on= "git@#{GIT_HOST["host"]}:"
= f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record?
.clearfix
= f.label :code do
Code
%cite= "http://#{GIT_HOST["host"]}/"
.input= f.text_field :code, :placeholder => "example"
.input
.input-prepend
%span.add-on= "http://#{GIT_HOST["host"]}/"
= f.text_field :code, :placeholder => "example"
- unless @project.new_record? || @project.heads.empty?
.clearfix
......
%ul.tabs
%li{ :class => "#{'active' if current_page?(project_path(@project)) }" }
= link_to project_path(@project), :class => "activities-tab tab" do
Activities
%li{ :class => "#{'active' if current_page?(info_project_path(@project)) || current_page?(edit_project_path(@project)) }" }
= link_to info_project_path(@project), :class => "stat-tab tab " do
Info
Show
- if can? current_user, :admin_project, @project
%li{ :class => "#{'active' if current_page?(edit_project_path(@project)) }" }
= link_to edit_project_path(@project), :class => "stat-tab tab " do
Edit
%li{ :class => " #{'active' if current_page?(team_project_path(@project)) }" }
%li{ :class => " #{'active' if (controller.controller_name == "team_members") || current_page?(team_project_path(@project)) }" }
= link_to team_project_path(@project), :class => "team-tab tab" do
Team
%li{ :class => "#{'active' if current_page?(files_project_path(@project)) }" }
= link_to files_project_path(@project), :class => "files-tab tab " do
Files
%li{ :class => " #{'active' if current_page?(project_snippets_path(@project)) }" }
%li{ :class => " #{'active' if (controller.controller_name == "snippets") }" }
= link_to project_snippets_path(@project), :class => "snippets-tab tab" do
Snippets
- if current_page?(project_snippets_path(@project))
- if can? current_user, :write_snippet, @project
%li
= link_to new_project_snippet_path(@project), :class => "add_new", :title => "New Snippet" do
Add new
- if current_page?(team_project_path(@project))
- if can? current_user, :admin_team_member, @project
%li
= link_to new_project_team_member_path(@project), :class => "add_new", :title => "New Team Member" do
Add New
= render "project_head"
.entry
%h3= @project.name
%br
%pre
= "git clone #{@project.url_to_repo}"
%h4 Details:
%table
%tr
%td Name
%td= @project.name
%tr
%td Slug
%td= @project.code
%tr
%td Path
%td= @project.path
%tr
%td Owner
%td= link_to @project.owner.name, project_team_member_path(@project, @project.team_member_by_id(@project.owner))
%tr
%td Last commit
%td
= time_ago_in_words(@project.commit.committed_date)
ago
%tr
%td Team
%td
= @project.users_projects.count
users
%tr
%td Open Issues
%td
= @project.issues.opened.count
%tr
%td Merge Requests
%td
= @project.merge_requests.opened.count
%tr
%td Created
%td= @project.created_at.stamp("Aug 21, 2011")
%tr
%td{:colspan => 2}= simple_format @project.description
%h4 Features:
%table
%tr
%td Issues
%td
- if @project.issues_enabled
.alert-message.success
Enabled
- else
.alert-message.error
Disabled
%tr
%td Merge Requests
%td
- if @project.merge_requests_enabled
.alert-message.success
Enabled
- else
.alert-message.error
Disabled
%tr
%td Wall
%td
- if @project.wall_enabled
.alert-message.success
Enabled
- else
.alert-message.error
Disabled
.actions
= link_to "Edit", edit_project_path(@project), :class => "btn"
= render "project_head"
- @activities.each do |update|
.entry
= link_to dashboard_feed_path(@project, update) do
- if update.kind_of? Note
%p
%strong
- if update.target
= update.target.class.name.titleize
= truncate update.target.id.to_s, :length => 10
commented
- else
Project wall
&ndash;
= image_tag gravatar_icon(update.author_email), :class => "", :width => 16
= truncate dashboard_feed_title(update), :length => 50
- else
%p
%strong
= update.class.name.titleize
= truncate update.id.to_s
&ndash;
= image_tag gravatar_icon(update.author_email), :class => "", :width => 16
= truncate dashboard_feed_title(update), :length => 50
%h3
= @project.name
%hr
.alert-message.block-message.warning
.input
.input-prepend
%span.add-on git clone
= text_field_tag :project_clone, @project.url_to_repo, :class => "xlarge one_click_select git_clone_url"
= simple_format @project.description
%h5.cgray Recent Activity
.content_list= render "feed"
= render "project_head"
- if can? current_user, :admin_team_member, @project
.alert-message.block-message
= link_to new_project_team_member_path(@project), :class => "btn small right", :title => "New Team Member" do
New Team Member
Manage project team from this page.
%br
To open team member profile - click on avatar.
= render :partial => "team", :locals => {:project => @project}
- if @project.valid?
:plain
location.href = "#{info_project_path(@project, :notice => 'Project was successfully updated.')}";
location.href = "#{edit_project_path(@project, :notice => 'Project was successfully updated.')}";
- else
:plain
$(".edit_project").replaceWith("#{escape_javascript(render('form'))}");
......
......@@ -4,10 +4,10 @@
%p
%strong
= commit.head.name
&ndash;
= truncate(commit.id.to_s, :length => 10)
%br
%code= commit.id.to_s[0..10]
= image_tag gravatar_icon(commit.author_email), :class => "", :width => 16
= truncate(commit.safe_message, :length => 40)
%span.right
%span.right.cgray
= time_ago_in_words(commit.committed_date)
ago
= render "head"
%h3
= @project.name
- if can? current_user, :download_code, @project
= link_to "Download", archive_project_repository_path(@project), :class => "btn small right"
%hr
.alert-message.block-message.warning
.input
.input-prepend
%span.add-on git clone
= text_field_tag :project_clone, @project.url_to_repo, :class => "xlarge one_click_select git_clone_url"
%p
Last commit was
%small
%code= @activities.first.commit.id.to_s[0..10]
= time_ago_in_words(@activities.first.commit.committed_date)
ago to
= link_to project_commits_path(@project, :ref => @activities.first.head.name), :class => "visible_link" do
= @activities.first.head.name
%h4.cgray
Recent Branches
%ul.unstyled
- @activities.each do |update|
= render "repositories/feed", :update => update, :project => @project
......
= render "head"
- unless @tags.empty?
%div.update-data.ui-box.ui-box-small
.data
- @tags.each do |tag|
%a.update-item{:href => project_commits_path(@project, :ref => tag.name)}
%span.update-title{:style => "margin-bottom:0px;"}
= tag.name
%span.update-author.right
= time_ago_in_words(tag.commit.committed_date)
ago
- @tags.each do |tag|
.row
.span7
.entry
= tag.name
%code= tag.commit.id.to_s[0..10]
%span.update-author.right
= time_ago_in_words(tag.commit.committed_date)
ago
.span3
- if can? current_user, :download_code, @project
= link_to "Download", archive_project_repository_path(@project, :ref => tag.name), :class => "btn small"
= link_to "Commits", project_commits_path(@project, :ref => tag.name), :class => "btn small"
- else
%h3 No tags
%h3= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr
= form_for [@project, @snippet] do |f|
%div
%span.entity-info
- if @snippet.new_record?
= link_to project_snippets_path(@project) do
.entity-button
Snippets
%i
- else
= link_to project_snippet_path(@project, @snippet) do
.entity-button
Show Snippet
%i
%h2= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr
%table.no-borders
-if @snippet.errors.any?
%tr
%td{:colspan => 2}
#error_explanation
- @snippet.errors.full_messages.each do |msg|
%span= msg
%br
.alert-message.block-message.error
%ul
- @snippet.errors.full_messages.each do |msg|
%li= msg
%tr
%td= f.label :title
%td= f.text_field :title, :placeholder => "Example Snippet"
%tr
%td= f.label :file_name
%td= f.text_field :file_name, :placeholder => "example.rb"
%tr
%td= f.label "Lifetime"
%td= f.select :expires_at, lifetime_select_options, {}, :style => "width:200px;"
%tr
%td{:colspan => 2}
= f.label :content, "Code"
%br
%br
= f.text_area :content
.clearfix
= f.label :title
.input= f.text_field :title, :placeholder => "Example Snippet"
.clearfix
= f.label :file_name
.input= f.text_field :file_name, :placeholder => "example.rb"
.clearfix
= f.label "Lifetime"
.input= f.select :expires_at, lifetime_select_options, {}, :style => "width:200px;"
.clearfix
= f.label :content, "Code"
= f.text_area :content, :class => "xxlarge"