Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
1bd28994
Commit
1bd28994
authored
Apr 09, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ProjectWiki instead of GollumWiki in code
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
26ec74c4
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
137 deletions
+19
-137
app/models/gollum_wiki.rb
app/models/gollum_wiki.rb
+0
-120
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+2
-2
features/steps/project/wiki.rb
features/steps/project/wiki.rb
+3
-3
lib/backup/repository.rb
lib/backup/repository.rb
+2
-2
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+3
-1
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+5
-5
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+1
-1
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+2
-2
spec/support/test_env.rb
spec/support/test_env.rb
+1
-1
No files found.
app/models/gollum_wiki.rb
deleted
100644 → 0
View file @
26ec74c4
class
GollumWiki
include
Gitlab
::
ShellAdapter
MARKUPS
=
{
"Markdown"
=>
:markdown
,
"RDoc"
=>
:rdoc
}
class
CouldNotCreateWikiError
<
StandardError
;
end
# Returns a string describing what went wrong after
# an operation fails.
attr_reader
:error_message
def
initialize
(
project
,
user
=
nil
)
@project
=
project
@user
=
user
end
def
path
@project
.
path
+
'.wiki'
end
def
path_with_namespace
@project
.
path_with_namespace
+
".wiki"
end
def
url_to_repo
gitlab_shell
.
url_to_repo
(
path_with_namespace
)
end
def
ssh_url_to_repo
url_to_repo
end
def
http_url_to_repo
[
Gitlab
.
config
.
gitlab
.
url
,
"/"
,
path_with_namespace
,
".git"
].
join
(
''
)
end
# Returns the Gollum::Wiki object.
def
wiki
@wiki
||=
begin
Gollum
::
Wiki
.
new
(
path_to_repo
)
rescue
Gollum
::
NoSuchPathError
create_repo!
end
end
def
empty?
pages
.
empty?
end
# Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages.
def
pages
wiki
.
pages
.
map
{
|
page
|
WikiPage
.
new
(
self
,
page
,
true
)
}
end
# Finds a page within the repository based on a tile
# or slug.
#
# title - The human readable or parameterized title of
# the page.
#
# Returns an initialized WikiPage instance or nil
def
find_page
(
title
,
version
=
nil
)
if
page
=
wiki
.
page
(
title
,
version
)
WikiPage
.
new
(
self
,
page
,
true
)
else
nil
end
end
def
create_page
(
title
,
content
,
format
=
:markdown
,
message
=
nil
)
commit
=
commit_details
(
:created
,
message
,
title
)
wiki
.
write_page
(
title
,
format
,
content
,
commit
)
rescue
Gollum
::
DuplicatePageError
=>
e
@error_message
=
"Duplicate page:
#{
e
.
message
}
"
return
false
end
def
update_page
(
page
,
content
,
format
=
:markdown
,
message
=
nil
)
commit
=
commit_details
(
:updated
,
message
,
page
.
title
)
wiki
.
update_page
(
page
,
page
.
name
,
format
,
content
,
commit
)
end
def
delete_page
(
page
,
message
=
nil
)
wiki
.
delete_page
(
page
,
commit_details
(
:deleted
,
message
,
page
.
title
))
end
private
def
create_repo!
if
init_repo
(
path_with_namespace
)
Gollum
::
Wiki
.
new
(
path_to_repo
)
else
raise
CouldNotCreateWikiError
end
end
def
init_repo
(
path_with_namespace
)
gitlab_shell
.
add_repository
(
path_with_namespace
)
end
def
commit_details
(
action
,
message
=
nil
,
title
=
nil
)
commit_message
=
message
||
default_message
(
action
,
title
)
{
email:
@user
.
email
,
name:
@user
.
name
,
message:
commit_message
}
end
def
default_message
(
action
,
title
)
"
#{
@user
.
username
}
#{
action
}
page:
#{
title
}
"
end
def
path_to_repo
@path_to_repo
||=
File
.
join
(
Gitlab
.
config
.
gitlab_shell
.
repos_path
,
"
#{
path_with_namespace
}
.git"
)
end
end
app/services/projects/create_service.rb
View file @
1bd28994
...
...
@@ -74,8 +74,8 @@ module Projects
if
@project
.
wiki_enabled?
begin
# force the creation of a wiki,
Gollum
Wiki
.
new
(
@project
,
@project
.
owner
).
wiki
rescue
Gollum
Wiki
::
CouldNotCreateWikiError
=>
ex
Project
Wiki
.
new
(
@project
,
@project
.
owner
).
wiki
rescue
Project
Wiki
::
CouldNotCreateWikiError
=>
ex
# Prevent project observer crash
# if failed to create wiki
nil
...
...
features/steps/project/wiki.rb
View file @
1bd28994
class
ProjectWiki
<
Spinach
::
FeatureSteps
class
Spinach::Features::
ProjectWiki
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedProject
include
SharedNote
...
...
@@ -16,7 +16,7 @@ class ProjectWiki < Spinach::FeatureSteps
end
Given
'I create the Wiki Home page'
do
fill_in
"
C
ontent"
,
with:
'[link test](test)'
fill_in
"
wiki_c
ontent"
,
with:
'[link test](test)'
click_on
"Create page"
end
...
...
@@ -87,6 +87,6 @@ class ProjectWiki < Spinach::FeatureSteps
end
def
wiki
@
gollum_wiki
=
Gollum
Wiki
.
new
(
project
,
current_user
)
@
project_wiki
=
Project
Wiki
.
new
(
project
,
current_user
)
end
end
lib/backup/repository.rb
View file @
1bd28994
...
...
@@ -24,7 +24,7 @@ module Backup
puts
"[FAILED]"
.
red
end
wiki
=
Gollum
Wiki
.
new
(
project
)
wiki
=
Project
Wiki
.
new
(
project
)
if
File
.
exists?
(
path_to_repo
(
wiki
))
print
" *
#{
wiki
.
path_with_namespace
}
... "
...
...
@@ -59,7 +59,7 @@ module Backup
puts
"[FAILED]"
.
red
end
wiki
=
Gollum
Wiki
.
new
(
project
)
wiki
=
Project
Wiki
.
new
(
project
)
if
File
.
exists?
(
path_to_bundle
(
wiki
))
print
" *
#{
wiki
.
path_with_namespace
}
... "
...
...
lib/redcarpet/render/gitlab_html.rb
View file @
1bd28994
...
...
@@ -60,6 +60,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
def
is_wiki?
@template
.
instance_variable_get
(
"@wiki"
)
if
@template
.
instance_variable_get
(
"@project_wiki"
)
@template
.
instance_variable_get
(
"@page"
)
end
end
end
spec/models/
gollum
_wiki_spec.rb
→
spec/models/
project
_wiki_spec.rb
View file @
1bd28994
require
"spec_helper"
describe
Gollum
Wiki
do
describe
Project
Wiki
do
def
remove_temp_repo
(
path
)
FileUtils
.
rm_rf
path
...
...
@@ -23,7 +23,7 @@ describe GollumWiki do
let
(
:user
)
{
project
.
owner
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
subject
{
Gollum
Wiki
.
new
(
project
,
user
)
}
subject
{
Project
Wiki
.
new
(
project
,
user
)
}
before
do
create_temp_repo
(
subject
.
send
(
:path_to_repo
))
...
...
@@ -68,15 +68,15 @@ describe GollumWiki do
end
it
"creates a new wiki repo if one does not yet exist"
do
wiki
=
Gollum
Wiki
.
new
(
project
,
user
)
wiki
=
Project
Wiki
.
new
(
project
,
user
)
wiki
.
create_page
(
"index"
,
"test content"
).
should_not
==
false
FileUtils
.
rm_rf
wiki
.
send
(
:path_to_repo
)
end
it
"raises CouldNotCreateWikiError if it can't create the wiki repository"
do
Gollum
Wiki
.
any_instance
.
stub
(
:init_repo
).
and_return
(
false
)
expect
{
GollumWiki
.
new
(
project
,
user
).
wiki
}.
to
raise_exception
(
Gollum
Wiki
::
CouldNotCreateWikiError
)
Project
Wiki
.
any_instance
.
stub
(
:init_repo
).
and_return
(
false
)
expect
{
ProjectWiki
.
new
(
project
,
user
).
wiki
}.
to
raise_exception
(
Project
Wiki
::
CouldNotCreateWikiError
)
end
end
...
...
spec/models/wiki_page_spec.rb
View file @
1bd28994
...
...
@@ -22,7 +22,7 @@ describe WikiPage do
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:user
)
{
project
.
owner
}
let
(
:wiki
)
{
Gollum
Wiki
.
new
(
project
,
user
)
}
let
(
:wiki
)
{
Project
Wiki
.
new
(
project
,
user
)
}
subject
{
WikiPage
.
new
(
wiki
)
}
...
...
spec/services/projects/create_service_spec.rb
View file @
1bd28994
...
...
@@ -42,7 +42,7 @@ describe Projects::CreateService do
context
'wiki_enabled true creates wiki repository directory'
do
before
do
@project
=
create_project
(
@user
,
@opts
)
@path
=
Gollum
Wiki
.
new
(
@project
,
@user
).
send
(
:path_to_repo
)
@path
=
Project
Wiki
.
new
(
@project
,
@user
).
send
(
:path_to_repo
)
end
it
{
File
.
exists?
(
@path
).
should
be_true
}
...
...
@@ -52,7 +52,7 @@ describe Projects::CreateService do
before
do
@opts
.
merge!
(
wiki_enabled:
false
)
@project
=
create_project
(
@user
,
@opts
)
@path
=
Gollum
Wiki
.
new
(
@project
,
@user
).
send
(
:path_to_repo
)
@path
=
Project
Wiki
.
new
(
@project
,
@user
).
send
(
:path_to_repo
)
end
it
{
File
.
exists?
(
@path
).
should
be_false
}
...
...
spec/support/test_env.rb
View file @
1bd28994
...
...
@@ -52,7 +52,7 @@ module TestEnv
def
setup_stubs
()
# Use tmp dir for FS manipulations
repos_path
=
testing_path
()
Gollum
Wiki
.
any_instance
.
stub
(
:init_repo
)
do
|
path
|
Project
Wiki
.
any_instance
.
stub
(
:init_repo
)
do
|
path
|
create_temp_repo
(
File
.
join
(
repos_path
,
"
#{
path
}
.git"
))
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment