[issue #64] Added Wiki controller and some methods in Project

This commit is contained in:
George Vinogradov 2011-12-23 21:01:47 +04:00
parent c1292d4873
commit 81378478ca
9 changed files with 100 additions and 1 deletions

View File

@ -30,6 +30,10 @@ gem 'whenever', :require => false
gem 'delayed_job'
gem 'highline', '~> 1.6.8'
# Wiki
gem "gollum", "1.3.1"
gem "redcarpet", "1.17.2"
# XML-RPC support
# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.git'
gem "rails-xmlrpc", '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git'

View File

@ -37,6 +37,8 @@ GEM
airbrake (3.0.5)
activesupport
builder
albino (1.3.3)
posix-spawn (>= 0.3.6)
ancestry (1.2.4)
activerecord (>= 2.2.2)
arel (2.0.10)
@ -77,6 +79,16 @@ GEM
factory_girl_rails (1.4.0)
factory_girl (~> 2.3.0)
railties (>= 3.0.0)
github-markup (0.7.0)
gollum (1.3.1)
albino (~> 1.3.2)
github-markup (>= 0.4.0, < 1.0.0)
grit (~> 2.4.1)
mustache (>= 0.11.2, < 1.0.0)
nokogiri (~> 1.4)
redcarpet
sanitize (~> 2.0.0)
sinatra (~> 1.0)
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
@ -105,6 +117,7 @@ GEM
meta-tags (1.2.4)
actionpack
mime-types (1.17.2)
mustache (0.99.4)
mysql2 (0.2.9)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
@ -113,6 +126,7 @@ GEM
net-ssh (2.2.1)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.0)
omniauth (1.0.1)
hashie (~> 1.2)
rack
@ -127,6 +141,7 @@ GEM
mime-types
pg (0.11.0)
polyglot (0.3.3)
posix-spawn (0.3.6)
rack (1.2.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
@ -159,6 +174,7 @@ GEM
rbx-require-relative (0.0.5)
rdoc (3.11)
json (~> 1.4)
redcarpet (1.17.2)
rr (1.0.4)
rspec (2.7.0)
rspec-core (~> 2.7.0)
@ -183,10 +199,16 @@ GEM
sexp_processor (~> 3.0)
russian (0.6.0)
i18n (>= 0.5.0)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sexp_processor (3.0.8)
silent-postgres (0.1.1)
sinatra (1.2.7)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
state_machine (0.9.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
@ -219,6 +241,7 @@ DEPENDENCIES
delayed_job
devise (~> 1.5.2)
factory_girl_rails (~> 1.4.0)
gollum (= 1.3.1)
grack!
grit
haml-rails (~> 0.3.4)
@ -236,6 +259,7 @@ DEPENDENCIES
rails-xmlrpc (~> 0.3.6)
rails3-generators
rails3-jquery-autocomplete
redcarpet (= 1.17.2)
rr
rspec-rails (~> 2.7.0)
ruby-debug

View File

@ -0,0 +1,19 @@
class WikiController < ApplicationController
def index
end
def show
end
def edit
end
def update
end
def new
end
def create
end
end

View File

@ -0,0 +1,2 @@
module WikiHelper
end

View File

@ -29,7 +29,10 @@ class Project < ActiveRecord::Base
after_create :attach_to_personal_repository
after_create :create_git_repo
after_save :create_wiki
after_destroy :destroy_git_repo
after_destroy :destroy_wiki
# after_rollback lambda { destroy_git_repo rescue true if new_record? }
has_ancestry
@ -111,6 +114,10 @@ class Project < ActiveRecord::Base
build_path(git_repo_name)
end
def wiki_path
build_wiki_path(git_repo_name)
end
def xml_rpc_create(repository)
result = BuildServer.create_project name, repository.platform.name, repository.name, path
if result == BuildServer::SUCCESS
@ -135,6 +142,10 @@ class Project < ActiveRecord::Base
File.join(APP_CONFIG['root_path'], 'git_projects', "#{dir}.git")
end
def build_wiki_path(dir)
File.join(APP_CONFIG['root_path'], 'projects_wiki', "#{dir}.wiki.git")
end
def attach_to_personal_repository
repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository)
end
@ -146,4 +157,12 @@ class Project < ActiveRecord::Base
def destroy_git_repo
FileUtils.rm_rf path
end
def create_wiki
Grit::Repo.init_bare(wiki_path) if has_wiki && !FileTest.exist?(wiki_path)
end
def destroy_wiki
FileUtils.rm_rf wiki_path
end
end

View File

@ -0,0 +1,9 @@
class AddHasWikiToProjects < ActiveRecord::Migration
def self.up
add_column :projects, :has_wiki, :boolean
end
def self.down
remove_column :projects, :has_wiki
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111220155059) do
ActiveRecord::Schema.define(:version => 20111221194422) do
create_table "arches", :force => true do |t|
t.string "name", :null => false
@ -69,6 +69,7 @@ ActiveRecord::Schema.define(:version => 20111220155059) do
t.string "update_type"
t.integer "bpl_id"
t.integer "pl_id"
t.text "include_repos"
t.integer "user_id"
end
@ -212,6 +213,7 @@ ActiveRecord::Schema.define(:version => 20111220155059) do
t.integer "category_id"
t.text "description"
t.string "ancestry"
t.boolean "has_wiki"
end
add_index "projects", ["category_id"], :name => "index_projects_on_category_id"

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe WikiController do
end

View File

@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the WikiHelper. For example:
#
# describe WikiHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe WikiHelper do
pending "add some examples to (or delete) #{__FILE__}"
end