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
Tatuya Kamada
gitlab-ce
Commits
2e8b5ebe
Commit
2e8b5ebe
authored
Sep 09, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1386 from tsigo/github_markup
Use GitHub::Markup to parse markup files
parents
ebd2a5d0
1814ee0c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
9 deletions
+34
-9
Gemfile
Gemfile
+2
-1
Gemfile.lock
Gemfile.lock
+2
-0
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+2
-0
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+10
-0
app/views/refs/_tree.html.haml
app/views/refs/_tree.html.haml
+1
-5
app/views/refs/_tree_file.html.haml
app/views/refs/_tree_file.html.haml
+2
-3
spec/helpers/tree_helper_spec.rb
spec/helpers/tree_helper_spec.rb
+15
-0
No files found.
Gemfile
View file @
2e8b5ebe
...
@@ -44,7 +44,8 @@ gem "ffaker"
...
@@ -44,7 +44,8 @@ gem "ffaker"
gem
"
seed-fu
"
gem
"
seed-fu
"
# Markdown to HTML
# Markdown to HTML
gem
"
redcarpet
"
,
"~> 2.1.1"
gem
"
redcarpet
"
,
"~> 2.1.1"
gem
"
github-markup
"
,
"~> 0.7.4"
# Servers
# Servers
gem
"
thin
"
gem
"
thin
"
...
...
Gemfile.lock
View file @
2e8b5ebe
...
@@ -178,6 +178,7 @@ GEM
...
@@ -178,6 +178,7 @@ GEM
gherkin (2.11.0)
gherkin (2.11.0)
json (>= 1.4.6)
json (>= 1.4.6)
git (1.2.5)
git (1.2.5)
github-markup (0.7.4)
gitlab_meta (2.9)
gitlab_meta (2.9)
grape (0.2.1)
grape (0.2.1)
hashie (~> 1.2)
hashie (~> 1.2)
...
@@ -396,6 +397,7 @@ DEPENDENCIES
...
@@ -396,6 +397,7 @@ DEPENDENCIES
ffaker
ffaker
foreman
foreman
git
git
github-markup (~> 0.7.4)
gitlab_meta (= 2.9)
gitlab_meta (= 2.9)
gitolite!
gitolite!
grack!
grack!
...
...
app/controllers/refs_controller.rb
View file @
2e8b5ebe
require
'github/markup'
class
RefsController
<
ApplicationController
class
RefsController
<
ApplicationController
include
Gitlab
::
Encode
include
Gitlab
::
Encode
before_filter
:project
before_filter
:project
...
...
app/helpers/tree_helper.rb
View file @
2e8b5ebe
...
@@ -24,4 +24,14 @@ module TreeHelper
...
@@ -24,4 +24,14 @@ module TreeHelper
content
.
name
content
.
name
end
end
end
end
# Public: Determines if a given filename is compatible with GitHub::Markup.
#
# filename - Filename string to check
#
# Returns boolean
def
markup?
(
filename
)
filename
.
end_with?
(
*
%w(.mdown .md .markdown .textile .rdoc .org .creole
.mediawiki .rst .asciidoc .pod)
)
end
end
end
app/views/refs/_tree.html.haml
View file @
2e8b5ebe
...
@@ -43,11 +43,7 @@
...
@@ -43,11 +43,7 @@
%i
.icon-file
%i
.icon-file
=
content
.
name
=
content
.
name
.file_content.wiki
.file_content.wiki
-
if
content
.
name
=~
/\.(md|markdown)$/i
=
raw
GitHub
::
Markup
.
render
(
content
.
name
,
content
.
data
)
=
preserve
do
=
markdown
(
content
.
data
)
-
else
=
simple_format
(
content
.
data
)
:javascript
:javascript
$
(
function
(){
$
(
function
(){
...
...
app/views/refs/_tree_file.html.haml
View file @
2e8b5ebe
...
@@ -9,10 +9,9 @@
...
@@ -9,10 +9,9 @@
=
link_to
"history"
,
project_commits_path
(
@project
,
path:
params
[
:path
],
ref:
@ref
),
class:
"btn very_small"
=
link_to
"history"
,
project_commits_path
(
@project
,
path:
params
[
:path
],
ref:
@ref
),
class:
"btn very_small"
=
link_to
"blame"
,
blame_file_project_ref_path
(
@project
,
@ref
,
path:
params
[
:path
]),
class:
"btn very_small"
=
link_to
"blame"
,
blame_file_project_ref_path
(
@project
,
@ref
,
path:
params
[
:path
]),
class:
"btn very_small"
-
if
file
.
text?
-
if
file
.
text?
-
if
name
=~
/\.(md|markdown)$/i
-
if
markup?
(
name
)
.file_content.wiki
.file_content.wiki
=
preserve
do
=
raw
GitHub
::
Markup
.
render
(
name
,
file
.
data
)
=
markdown
(
file
.
data
)
-
else
-
else
.file_content.code
.file_content.code
-
unless
file
.
empty?
-
unless
file
.
empty?
...
...
spec/helpers/tree_helper_spec.rb
0 → 100644
View file @
2e8b5ebe
require
'spec_helper'
describe
TreeHelper
do
describe
'#markup?'
do
%w(mdown md markdown textile rdoc org creole mediawiki rst asciidoc pod)
.
each
do
|
type
|
it
"returns true for
#{
type
}
files"
do
markup?
(
"README.
#{
type
}
"
).
should
be_true
end
end
it
"returns false when given a non-markup filename"
do
markup?
(
'README.rb'
).
should_not
be_true
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