From a7fab42b9cd34ddd44ff2ab0837691f57428b8e4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 27 Jul 2013 21:23:35 +0300 Subject: [PATCH] Public area: Project#show page prototype --- app/assets/stylesheets/sections/projects.scss | 16 +++++++++++++--- app/controllers/public/projects_controller.rb | 8 ++++++++ app/views/layouts/public.html.haml | 8 +++++++- app/views/public/projects/index.html.haml | 22 ++++++++++------------ app/views/public/projects/show.html.haml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ config/routes.rb | 2 ++ 6 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 app/views/public/projects/show.html.haml diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index 58f98f4..52ef30b 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -81,9 +81,11 @@ ul.nav.nav-projects-tabs { .public-projects { li { - margin-top: 8px; - margin-bottom: 5px; - border-bottom: 1px solid #eee; + .project-title { + font-size: 14px; + line-height: 2; + font-weight: normal; + } .description { margin-left: 15px; @@ -92,6 +94,14 @@ ul.nav.nav-projects-tabs { } } +.public-clone { + background: #333; + color: #f5f5f5; + padding: 5px 10px; + margin: 1px; + font-weight: normal; +} + .new-tag-btn { position: relative; top: -5px; diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb index 6c0b397..5d830de 100644 --- a/app/controllers/public/projects_controller.rb +++ b/app/controllers/public/projects_controller.rb @@ -10,4 +10,12 @@ class Public::ProjectsController < ApplicationController @projects = @projects.search(params[:search]) if params[:search].present? @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) end + + def show + @project = Project.public_only.find_with_namespace(params[:id]) + render_404 and return unless @project + + @repository = @project.repository + @recent_tags = @repository.tags.first(10) + end end diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index e330da9..4a06d63 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -10,10 +10,16 @@ .container %div.app_logo %span.separator - = link_to root_path, class: "home" do + = link_to public_root_path, class: "home" do %h1 GITLAB %span.separator %h1.project_name Public Projects + %ul.nav + %li + %a + %div.hide.turbolink-spinner + %i.icon-refresh.icon-spin + Loading... .container.navless-container .content diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index 4bc67d8..e933268 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -11,22 +11,20 @@ = search_field_tag :search, params[:search], placeholder: "gitlab-ci", class: "span3 search-text-input", id: "projects_search" = submit_tag 'Search', class: "btn btn-primary wide" -%hr - .public-projects - %ul.unstyled + %ul.bordered-list - @projects.each do |project| - %li.clearfix - %div - %i.icon-share - - if current_user - = link_to_project project - - else + %li + .project-title + %i.icon-share.cgray + = link_to public_project_path(project) do = project.name_with_namespace .pull-right - %pre.dark.tiny git clone #{project.http_url_to_repo} - %div.description - = project.description + %pre.public-clone git clone #{project.http_url_to_repo} + + - if project.description.present? + %div.description + = project.description - unless @projects.present? %h3.nothing_here_message No public projects diff --git a/app/views/public/projects/show.html.haml b/app/views/public/projects/show.html.haml new file mode 100644 index 0000000..e2c8755 --- /dev/null +++ b/app/views/public/projects/show.html.haml @@ -0,0 +1,47 @@ +%h3.page-title + = @project.name_with_namespace + .pull-right + %pre.public-clone git clone #{@project.http_url_to_repo} + .pull-right + - if current_user + = link_to 'Browse project', @project, class: 'btn btn-create append-right-10' + + +%div + = link_to public_root_path do + ← To projects list + .pull-right + %span.light= @project.description + +%br +.row + .span9 + .light-well + %h3.nothing_here_message Some awesome stuff here + .span3 + %h5 Repository: + %div + %p + %span.light Bare size is + #{@project.repository.size} MB + + %p + = pluralize(@repository.round_commit_count, 'commit') + %p + = pluralize(@repository.branch_names.count, 'branch') + %p + = pluralize(@repository.tag_names.count, 'tag') + + - if @recent_tags.present? + %hr + %h5 Most Recent Tags: + %ul.unstyled + - @recent_tags.each do |tag| + %li + %p + %i.icon-tag + %strong= tag.name + %small.light.pull-right + %i.icon-calendar + = time_ago_in_words(tag.commit.committed_date) + ago diff --git a/config/routes.rb b/config/routes.rb index 2d9875e..d303a57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,6 +55,8 @@ Gitlab::Application.routes.draw do # namespace :public do resources :projects, only: [:index] + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:show] + root to: "projects#index" end -- libgit2 0.21.2