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
Jérome Perrin
gitlab-ce
Commits
7ff9c822
Commit
7ff9c822
authored
Jan 08, 2015
by
Hannes Rosenögger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a service to support external wikis
parent
d66148ef
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
2 deletions
+102
-2
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+1
-1
app/helpers/external_wiki_helper.rb
app/helpers/external_wiki_helper.rb
+11
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/models/project_services/external_wiki_service.rb
app/models/project_services/external_wiki_service.rb
+48
-0
app/views/layouts/nav/_project.html.haml
app/views/layouts/nav/_project.html.haml
+1
-1
spec/models/external_wiki_service_spec.rb
spec/models/external_wiki_service_spec.rb
+39
-0
No files found.
CHANGELOG
View file @
7ff9c822
...
...
@@ -9,6 +9,7 @@ v 7.9.0 (unreleased)
- Fix merge request URL passed to Webhooks. (Stan Hu)
- Fix bug that caused a server error when editing a comment to "+1" or "-1" (Stan Hu)
- Fix code preview theme setting for comments, issues, merge requests, and snippets (Stan Hu)
- Add a service to support external wikis (Hannes Rosenögger)
- Move labels/milestones tabs to sidebar
- Upgrade Rails gem to version 4.1.9.
- Improve error messages for file edit failures
...
...
app/controllers/projects/services_controller.rb
View file @
7ff9c822
...
...
@@ -53,7 +53,7 @@ class Projects::ServicesController < Projects::ApplicationController
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:channel
,
:colorize_messages
,
:channels
,
:push_events
,
:issues_events
,
:merge_requests_events
,
:tag_push_events
,
:note_events
,
:send_from_committer_email
,
:disable_diffs
:note_events
,
:send_from_committer_email
,
:disable_diffs
,
:external_wiki_url
)
end
end
app/helpers/external_wiki_helper.rb
0 → 100644
View file @
7ff9c822
module
ExternalWikiHelper
def
get_project_wiki_path
(
project
)
external_wiki_service
=
project
.
services
.
select
{
|
service
|
service
.
to_param
==
'external_wiki'
}.
first
if
external_wiki_service
.
present?
&&
external_wiki_service
.
active?
external_wiki_service
.
properties
[
'external_wiki_url'
]
else
namespace_project_wiki_path
(
project
.
namespace
,
project
,
:home
)
end
end
end
app/models/project.rb
View file @
7ff9c822
...
...
@@ -93,6 +93,7 @@ class Project < ActiveRecord::Base
has_one
:forked_project_link
,
dependent: :destroy
,
foreign_key:
"forked_to_project_id"
has_one
:forked_from_project
,
through: :forked_project_link
has_one
:external_wiki_service
,
dependent: :destroy
# Merge Requests for target project should be removed with it
has_many
:merge_requests
,
dependent: :destroy
,
foreign_key:
'target_project_id'
# Merge requests from source project should be kept when source project was removed
...
...
app/models/project_services/external_wiki_service.rb
0 → 100644
View file @
7ff9c822
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# properties :text
#
class
ExternalWikiService
<
Service
include
HTTParty
prop_accessor
:external_wiki_url
validates
:external_wiki_url
,
presence:
true
,
format:
{
with:
URI
::
regexp
},
if: :activated?
def
title
'External Wiki'
end
def
description
'Replaces the link to the internal wiki with a link to an external wiki.'
end
def
to_param
'external_wiki'
end
def
fields
[
{
type:
'text'
,
name:
'external_wiki_url'
,
placeholder:
'The URL of the external Wiki'
},
]
end
def
execute
(
_data
)
@response
=
HTTParty
.
get
(
properties
[
'external_wiki_url'
],
verify:
true
)
rescue
nil
if
@response
!=
200
nil
end
end
end
app/views/layouts/nav/_project.html.haml
View file @
7ff9c822
...
...
@@ -75,7 +75,7 @@
-
if
project_nav_tab?
:wiki
=
nav_link
(
controller: :wikis
)
do
=
link_to
namespace_project_wiki_path
(
@project
.
namespace
,
@project
,
:home
),
title:
'Wiki'
,
class:
'shortcuts-wiki'
do
=
link_to
get_project_wiki_path
(
@project
),
title:
'Wiki'
,
class:
'shortcuts-wiki'
do
%i
.fa.fa-book
%span
Wiki
...
...
spec/models/external_wiki_service_spec.rb
0 → 100644
View file @
7ff9c822
require
'spec_helper'
describe
ExternalWikiService
do
include
ExternalWikiHelper
describe
"Associations"
do
it
{
should
belong_to
:project
}
it
{
should
have_one
:service_hook
}
end
describe
"Validations"
do
context
"active"
do
before
do
subject
.
active
=
true
end
it
{
should
validate_presence_of
:external_wiki_url
}
end
end
describe
'External wiki'
do
let
(
:project
)
{
create
(
:project
)
}
context
'when it is active'
do
before
do
properties
=
{
'external_wiki_url'
=>
'https://gitlab.com'
}
@service
=
project
.
create_external_wiki_service
(
active:
true
,
properties:
properties
)
end
after
do
@service
.
destroy!
end
it
'should replace the wiki url'
do
wiki_path
=
get_project_wiki_path
(
project
)
wiki_path
.
should
match
(
'https://gitlab.com'
)
end
end
end
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