Permalink
Browse files

Release 0.0.5

  • Loading branch information...
2 parents b421daf + 095cb16 commit 87c69072e038bea0e54d7af9eeb6cc9538bcc1cb @Vanuan Vanuan committed Jul 8, 2012
View
@@ -0,0 +1,5 @@
+source :rubygems
+
+gem "grit", "~> 2.5.0"
+gem "gollum", :git => 'git://github.com/github/gollum.git'
+
@@ -1,7 +1,9 @@
+require_dependency 'user'
+
class GollumController < ApplicationController
unloadable
- before_filter :find_project, :authorize
+ before_filter :find_project, :find_wiki, :authorize
def index
redirect_to :action => :show, :id => "Home"
@@ -16,7 +18,7 @@ def show
def edit
@name = params[:id]
@page = @wiki.page(@name)
- @content = @page ? @page.raw_data : ""
+ @content = @page ? @page.text_data : ""
end
def update
@@ -42,11 +44,12 @@ def project_repository_path
end
def show_page(name)
- @name = name
-
if page = @wiki.page(name)
- @page = page
- @content = page.formatted_data
+ @page_name = page.name
+ @page_title = page.title
+ @page_content = page.formatted_data.html_safe
+ else
+ redirect_to :action => :edit, :id => name
end
end
@@ -57,16 +60,24 @@ def find_project
end
@project = Project.find(params[:project_id])
+ end
+ def find_wiki
git_path = project_repository_path
unless File.directory? git_path
Grit::Repo.init_bare(git_path)
end
wiki_dir = @project.gollum_wiki.directory
+ if wiki_dir.empty?
+ wiki_dir = nil
+ end
- @wiki = Gollum::Wiki.new(git_path, :base_path => gollum_index_path(:project_id => @project.identifier), :page_file_dir => wiki_dir)
+ gollum_base_path = project_gollum_index_path
+ @wiki = Gollum::Wiki.new(git_path,
+ :base_path => gollum_base_path,
+ :page_file_dir => wiki_dir)
end
end
@@ -1,4 +1,4 @@
-<% form_for :page, :url => gollum_path(:id => @name), :html => { :method => "put" } do |f| -%>
+<%= form_for :page, :url => project_gollum_path(:id => @name), :html => { :method => "put" } do |f| -%>
<%= f.text_area :raw_data, :class => "wiki-edit", :cols => 100, :row => 25 %>
<p><%= f.submit(l(:button_save)) %></p>
<% end %>
@@ -1,3 +0,0 @@
-<div>
-<%= @content %>
-</div>
@@ -1,9 +1,14 @@
<div class="contextual">
<% if @editable %>
-<%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @name}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
+ <%= link_to_if_authorized(
+ l(:button_edit),
+ {:action => 'edit', :id => @page_name},
+ :class => 'icon icon-edit',
+ :accesskey => accesskey(:edit))
+ %>
<% end %>
</div>
-
-<div class="wiki">
-<%= @content %>
+<div class="wiki wiki-page">
+<h1><%= @page_title %></h1>
+<%= @page_content %>
</div>
@@ -1,4 +1,4 @@
-<% form_for @gollum_wiki, :url => { :controller => 'gollum_wikis', :action=> 'update', :project_id => @project } do |f| %>
+<%= form_for @gollum_wiki, :url => { :controller => 'gollum_wikis', :action=> 'update', :project_id => @project } do |f| %>
<div class="box tabular">
<p>
View
@@ -1,4 +1,4 @@
-ActionController::Routing::Routes.draw do |map|
- map.resources :gollum, :path_prefix => '/projects/:project_id'
- map.resource :gollum_wiki, :path_prefix => '/projects/:project_id'
+resources :projects do
+ resources :gollum
+ resource :gollum_wiki
end
View
19 init.rb
@@ -1,18 +1,12 @@
-require 'grit'
-require 'gollum' # min version 1.2.0
require 'redmine'
-require 'dispatcher'
-Dispatcher.to_prepare :redmine_model_dependencies do
- require_dependency 'project'
- require_dependency 'user'
- require_dependency 'projects_helper'
+Rails.configuration.to_prepare do
+ require 'grit'
+ require 'gollum'
+ require_dependency 'gollum_project_model_patch'
require_dependency 'gollum_projects_helper_patch'
- require_dependency 'projects_controller'
require_dependency 'gollum_projects_controller_patch'
-end
-Dispatcher.to_prepare :redmine_gollum do
# project model should be patched before projects controller
Project.send(:include, GollumProjectModelPatch) unless Project.included_modules.include?(GollumProjectModelPatch)
ProjectsController.send(:include, GollumProjectsControllerPatch) unless ProjectsController.included_modules.include?(GollumProjectsControllerPatch)
@@ -25,14 +19,13 @@
description 'A gollum plugin for redmine'
# use git to get version name
- require 'grit'
- repo = Grit::Repo.new("#{RAILS_ROOT}/vendor/plugins/redmine-gollum/.git")
+ repo = Grit::Repo.new("#{Rails.root}/plugins/redmine_gollum/.git")
version repo.recent_tag_name('HEAD', :tags=>true)
url 'https://github.com/gugod/redmine-gollum/'
author_url 'http://gugod.org'
- requires_redmine :version_or_higher => '1.1.0'
+ requires_redmine :version_or_higher => '2.0.2'
settings :default => {
:gollum_base_path => Pathname.new(Rails.root + "gollum")
@@ -1,3 +1,5 @@
+require_dependency 'project'
+
module GollumProjectModelPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
@@ -1,3 +1,5 @@
+require_dependency 'projects_controller'
+
module GollumProjectsControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
@@ -1,3 +1,5 @@
+require_dependency 'projects_helper'
+
module GollumProjectsHelperPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)

0 comments on commit 87c6907

Please sign in to comment.