[issue #64] Added git access to Wiki.

This commit is contained in:
George Vinogradov 2012-01-20 19:01:59 +04:00
parent 364f2e40c0
commit 011efb0c4b
17 changed files with 209 additions and 8 deletions

View File

@ -102,6 +102,9 @@ class WikiController < ApplicationController
redirect_to project_wiki_index_path(@project) redirect_to project_wiki_index_path(@project)
end end
def git
end
def compare def compare
@name = params[:id] @name = params[:id]
if request.post? if request.post?

View File

@ -6,4 +6,8 @@ module ProjectsHelper
"http://#{request.host_with_port}/#{name}.git" "http://#{request.host_with_port}/#{name}.git"
end end
end end
def git_wiki_repo_url(name)
git_repo_url("#{name}.wiki")
end
end end

View File

@ -148,7 +148,7 @@ class Project < ActiveRecord::Base
end end
def build_wiki_path(dir) def build_wiki_path(dir)
File.join(APP_CONFIG['root_path'], 'projects_wiki', "#{dir}.wiki.git") File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.wiki.git")
end end
def attach_to_personal_repository def attach_to_personal_repository

View File

@ -0,0 +1,23 @@
.url-box
%ul.clone-urls
%li.http-clone-url.selected
= link_to t("layout.wiki.clones.http"), git_wiki_repo_url(@project.name),
:'data-permissions' => (can? @project, :write) ? 'Read+Write' : 'Read'
%input.url-field{:type => 'text', :spellcheck => 'false'}
%p.url-description
%strong
access
:javascript
$(document).ready(function() {
var link = $('li.http-clone-url a').first();
$('.url-box input.url-field').attr('value', link.attr('href'));
$('.url-box p.url-description strong').text(link.attr('data-permissions'));
$('li.http-clone-url a').live('click', function(e) {
e.preventDefault();
$('.url-box input.url-field').attr('value', $(this).attr('href'));
$('.url-box p.url-description strong').text($(this).attr('data-permissions'));
});
});

View File

@ -0,0 +1,17 @@
#template
%p
Your wiki data can be cloned from a git repository for offline access.
You have several options for editing it at this point:
%ol
%li
With your favorite text editor or IDE.
%li
With the built-in web interface, included with the
= link_to 'Gollum', "https://github.com/github/gollum"
Ruby API.
%li
With the Gollum Ruby API.
%p
When you're done, you can simply push your changes back to our system to
see them reflected on the site. The wiki repositories obey the same
access rules as the source repository that they belong to.

View File

@ -0,0 +1,18 @@
#template
%p
Все данные вашей Wiki могут быть клонированы из Git-репозитория для
доступа без интернета. В этом случае вы можете редактировать страницы
следующими способами:
%ol
%li
Вашим любимым текстовым редактором или IDE.
%li
С помощью встроенного Web-интерфейса, включенного в
= link_to 'Gollum', "https://github.com/github/gollum"
Ruby API.
%li
С помощью Gollum Ruby API.
%p
Когда изменения будут завершены, просто запуште их обратно в нашу систему
чтобы увидеть их на сайте. Доступ к репозиторию Wiki осуществляется с теми
же правами, что и к проекту, с которым она связана.

View File

@ -9,7 +9,7 @@
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li{:class => (!@name and action_name == 'compare') ? 'active' : ''} %li{:class => (!@name and action_name == 'compare') ? 'active' : ''}
= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) = link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
#wiki-wrapper.inner.compare #wiki-wrapper.inner.compare

View File

@ -8,7 +8,7 @@
%li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project) %li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) %li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
#wiki-wrapper.inner #wiki-wrapper.inner

View File

@ -0,0 +1,27 @@
= render :partial => 'gollum_includes'
= render :partial => 'project_short'
%a{ :name => "wiki"}
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li.active= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content
#wiki-wrapper.inner.compare
#head
%h1.title
= t("layout.wiki.wiki_git_access")
#wiki-content
= render :partial => "git_access"
%br
= render :partial => "git_access_message"
- content_for :sidebar do
- render :partial => 'projects/sidebar'

View File

@ -9,7 +9,7 @@
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li{:class => (!@name and action_name == 'history') ? 'active' : ''} %li{:class => (!@name and action_name == 'history') ? 'active' : ''}
= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) = link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
#wiki-wrapper.inner.history #wiki-wrapper.inner.history

View File

@ -8,7 +8,7 @@
%li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project) %li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) %li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
#wiki-wrapper.inner #wiki-wrapper.inner

View File

@ -9,7 +9,7 @@
= link_to t("layout.wiki.home"), project_wiki_index_path(@project) = link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li.active= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li.active= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) %li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
.inner .inner

View File

@ -8,7 +8,7 @@
%li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project) %li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) %li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
.inner .inner

View File

@ -9,7 +9,7 @@
= link_to t("layout.wiki.home"), project_wiki_index_path(@project) = link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project) %li= link_to t("layout.wiki.wiki_history"), history_project_wiki_index_path(@project)
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), git_project_wiki_index_path(@project)
.content .content
.inner .inner

View File

@ -171,6 +171,7 @@ ru:
delete_page: Удалить страницу delete_page: Удалить страницу
page_history: История page_history: История
create_page: Создать страницу create_page: Создать страницу
wiki_git_access: Доступ к Wiki через Git
page_title: Заголовок страницы page_title: Заголовок страницы
expand_collapse: Развернуть expand_collapse: Развернуть
last_edited_by: Последним редактировал last_edited_by: Последним редактировал
@ -202,6 +203,9 @@ ru:
search_results_for: "Результаты поиска для %{query}:" search_results_for: "Результаты поиска для %{query}:"
preview: Предпросмотр preview: Предпросмотр
clones:
http: HTTP
editor: editor:
bold: Жирный bold: Жирный
italic: Курсив italic: Курсив

View File

@ -35,6 +35,7 @@ module Grack
@project ||= begin @project ||= begin
uname, name = @env['PATH_INFO'].split('/')[1,2] uname, name = @env['PATH_INFO'].split('/')[1,2]
name.gsub! /\.git$/, '' name.gsub! /\.git$/, ''
name.gsub! /\.wiki$/, ''
owner = User.find_by_uname(uname) || Group.find_by_uname(uname) owner = User.find_by_uname(uname) || Group.find_by_uname(uname)
Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_name(name) Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_name(name)
end end

View File

@ -460,6 +460,110 @@
} }
/* git_access */
#wiki-content .url-box {
border: medium none;
margin-left: 0;
padding: 0;
}
.url-box {
border-top: 1px solid #DDDDDD;
height: 23px;
margin-left: -10px;
margin-top: 10px;
padding: 10px 10px 0;
width: 100%;
}
#wiki-content .url-box ul.clone_urls {
float: left;
height: 23px;
margin: 0;
}
#wiki-content ul.clone-urls li.selected {
border-right-color: #BBBBBB;
}
#wiki-content ul.clone-urls li {
border: medium none;
cursor: pointer;
float: left;
height: 23px;
list-style-type: none;
margin: 0;
overflow: visible;
padding: 0;
white-space: nowrap;
}
ul.clone-urls li {
list-style-type: none;
margin: 5px 0 0;
}
.url-box p {
color: #666666;
float: left;
font-size: 11px;
height: 23px;
line-height: 23px;
margin: 0 0 0 5px;
}
#wiki-content ul.clone-urls li.selected > a {
background: -moz-linear-gradient(center top , #D7D7D7, #ABABAB) repeat scroll 0 0 transparent;
border-color: #C9C9C9 #C9C9C9 #9A9A9A;
color: #000000;
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6);
}
#wiki-content ul.clone-urls li:first-child a {
border-bottom-left-radius: 3px;
border-left: 1px solid #D4D4D4;
border-top-left-radius: 3px;
}
#wiki-content ul.clone-urls li > a {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: -moz-linear-gradient(center top , #F4F4F4, #ECECEC) repeat scroll 0 0 transparent;
border-color: #D4D4D4 #D4D4D4 #D4D4D4 -moz-use-text-color;
border-style: solid solid solid none;
border-width: 1px 1px 1px medium;
color: #333333;
display: block;
font-size: 11px;
font-weight: bold;
height: 21px;
line-height: 21px;
margin: 0;
padding: 0 9px;
text-decoration: none;
text-shadow: 1px 1px 0 #FFFFFF;
}
#wiki-content input.url-field {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-color: #CCCCCC #CCCCCC #CCCCCC -moz-use-text-color;
border-style: solid solid solid none;
border-width: 1px 1px 1px medium;
color: #666666;
float: left;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
font-size: 11px;
height: 16px;
padding: 3px 5px 2px;
width: 400px;
}
/* @control syntax */ /* @control syntax */
.highlight { background: #ffffff; } .highlight { background: #ffffff; }