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
Léo-Paul Géneau
gitlab-ce
Commits
00fc9f26
Commit
00fc9f26
authored
May 08, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load tree readme asynchronously
parent
ecc6cc8b
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
42 additions
and
16 deletions
+42
-16
app/assets/javascripts/blob/viewer/index.js
app/assets/javascripts/blob/viewer/index.js
+4
-1
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-0
app/models/readme_blob.rb
app/models/readme_blob.rb
+13
-0
app/models/repository.rb
app/models/repository.rb
+1
-1
app/models/tree.rb
app/models/tree.rb
+1
-4
app/views/projects/_readme.html.haml
app/views/projects/_readme.html.haml
+3
-3
app/views/projects/blob/_viewer.html.haml
app/views/projects/blob/_viewer.html.haml
+2
-2
app/views/projects/tree/_readme.html.haml
app/views/projects/tree/_readme.html.haml
+3
-3
changelogs/unreleased/dm-async-tree-readme.yml
changelogs/unreleased/dm-async-tree-readme.yml
+4
-0
features/project/project.feature
features/project/project.feature
+1
-0
features/project/source/markdown_render.feature
features/project/source/markdown_render.feature
+3
-0
features/steps/project/project.rb
features/steps/project/project.rb
+2
-0
features/steps/project/source/markdown_render.rb
features/steps/project/source/markdown_render.rb
+1
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+1
-1
spec/views/projects/tree/show.html.haml_spec.rb
spec/views/projects/tree/show.html.haml_spec.rb
+1
-1
No files found.
app/assets/javascripts/blob/viewer/index.js
View file @
00fc9f26
...
@@ -8,7 +8,10 @@ export default class BlobViewer {
...
@@ -8,7 +8,10 @@ export default class BlobViewer {
this
.
richViewer
=
document
.
querySelector
(
'
.blob-viewer[data-type="rich"]
'
);
this
.
richViewer
=
document
.
querySelector
(
'
.blob-viewer[data-type="rich"]
'
);
this
.
$fileHolder
=
$
(
'
.file-holder
'
);
this
.
$fileHolder
=
$
(
'
.file-holder
'
);
let
initialViewerName
=
document
.
querySelector
(
'
.blob-viewer:not(.hidden)
'
).
getAttribute
(
'
data-type
'
);
const
initialViewer
=
document
.
querySelector
(
'
.blob-viewer:not(.hidden)
'
);
if
(
!
initialViewer
)
return
;
let
initialViewerName
=
initialViewer
.
getAttribute
(
'
data-type
'
);
this
.
initBindings
();
this
.
initBindings
();
...
...
app/assets/javascripts/dispatcher.js
View file @
00fc9f26
...
@@ -246,6 +246,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
...
@@ -246,6 +246,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
new
NotificationsForm
();
new
NotificationsForm
();
if
(
$
(
'
#tree-slider
'
).
length
)
{
if
(
$
(
'
#tree-slider
'
).
length
)
{
new
TreeView
();
new
TreeView
();
new
BlobViewer
();
}
}
break
;
break
;
case
'
projects:pipelines:builds
'
:
case
'
projects:pipelines:builds
'
:
...
@@ -300,6 +301,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
...
@@ -300,6 +301,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
case
'
projects:tree:show
'
:
case
'
projects:tree:show
'
:
shortcut_handler
=
new
ShortcutsNavigation
();
shortcut_handler
=
new
ShortcutsNavigation
();
new
TreeView
();
new
TreeView
();
new
BlobViewer
();
gl
.
TargetBranchDropDown
.
bootstrap
();
gl
.
TargetBranchDropDown
.
bootstrap
();
break
;
break
;
case
'
projects:find_file:show
'
:
case
'
projects:find_file:show
'
:
...
...
app/models/readme_blob.rb
0 → 100644
View file @
00fc9f26
class
ReadmeBlob
<
SimpleDelegator
attr_reader
:repository
def
initialize
(
blob
,
repository
)
@repository
=
repository
super
(
blob
)
end
def
rendered_markup
repository
.
rendered_readme
end
end
app/models/repository.rb
View file @
00fc9f26
...
@@ -518,7 +518,7 @@ class Repository
...
@@ -518,7 +518,7 @@ class Repository
def
readme
def
readme
if
head
=
tree
(
:head
)
if
head
=
tree
(
:head
)
head
.
readme
ReadmeBlob
.
new
(
head
.
readme
,
self
)
end
end
end
end
...
...
app/models/tree.rb
View file @
00fc9f26
...
@@ -40,10 +40,7 @@ class Tree
...
@@ -40,10 +40,7 @@ class Tree
readme_path
=
path
==
'/'
?
readme_tree
.
name
:
File
.
join
(
path
,
readme_tree
.
name
)
readme_path
=
path
==
'/'
?
readme_tree
.
name
:
File
.
join
(
path
,
readme_tree
.
name
)
git_repo
=
repository
.
raw_repository
@readme
=
repository
.
blob_at
(
sha
,
readme_path
)
@readme
=
Gitlab
::
Git
::
Blob
.
find
(
git_repo
,
sha
,
readme_path
)
@readme
.
load_all_data!
(
git_repo
)
@readme
end
end
def
trees
def
trees
...
...
app/views/projects/_readme.html.haml
View file @
00fc9f26
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
%article
.readme-holder
%article
.readme-holder
.pull-right
.pull-right
-
if
can?
(
current_user
,
:push_code
,
@project
)
-
if
can?
(
current_user
,
:push_code
,
@project
)
=
link_to
icon
(
'pencil'
),
namespace_project_edit_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@repository
.
root_ref
,
readme
.
name
)),
class:
'light edit-project-readme'
=
link_to
icon
(
'pencil'
),
namespace_project_edit_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@repository
.
root_ref
,
readme
.
path
)),
class:
'light edit-project-readme'
.file-content.wiki
=
markup
(
readme
.
name
,
readme
.
data
,
rendered:
@repository
.
rendered_readme
)
=
render
'projects/blob/viewer'
,
viewer:
readme
.
rich_viewer
,
viewer_url:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@repository
.
root_ref
,
readme
.
path
),
viewer: :rich
,
format: :json
)
-
else
-
else
.row-content-block.second-block.center
.row-content-block.second-block.center
%h3
.page-title
%h3
.page-title
...
...
app/views/projects/blob/_viewer.html.haml
View file @
00fc9f26
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
-
render_error
=
viewer
.
render_error
-
render_error
=
viewer
.
render_error
-
load_asynchronously
=
local_assigns
.
fetch
(
:load_asynchronously
,
viewer
.
server_side?
)
&&
render_error
.
nil?
-
load_asynchronously
=
local_assigns
.
fetch
(
:load_asynchronously
,
viewer
.
server_side?
)
&&
render_error
.
nil?
-
url
=
url_for
(
params
.
merge
(
viewer:
viewer
.
type
,
format: :json
))
if
load_asynchronously
-
viewer_url
=
local_assigns
.
fetch
(
:viewer_url
)
{
url_for
(
params
.
merge
(
viewer:
viewer
.
type
,
format: :json
))
}
if
load_asynchronously
.blob-viewer
{
data:
{
type:
viewer
.
type
,
url:
url
},
class:
(
'hidden'
if
hidden
)
}
.blob-viewer
{
data:
{
type:
viewer
.
type
,
url:
viewer_
url
},
class:
(
'hidden'
if
hidden
)
}
-
if
load_asynchronously
-
if
load_asynchronously
.text-center.prepend-top-default.append-bottom-default
.text-center.prepend-top-default.append-bottom-default
=
icon
(
'spinner spin 2x'
,
'aria-hidden'
=>
'true'
,
'aria-label'
=>
'Loading content'
)
=
icon
(
'spinner spin 2x'
,
'aria-hidden'
=>
'true'
,
'aria-label'
=>
'Loading content'
)
...
...
app/views/projects/tree/_readme.html.haml
View file @
00fc9f26
%article
.file-holder.readme-holder
%article
.file-holder.readme-holder
.js-file-title.file-title
.js-file-title.file-title
=
blob_icon
readme
.
mode
,
readme
.
name
=
blob_icon
readme
.
mode
,
readme
.
name
=
link_to
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@ref
,
@path
,
readme
.
name
))
do
=
link_to
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@ref
,
readme
.
path
))
do
%strong
%strong
=
readme
.
name
=
readme
.
name
.file-content.wiki
=
markup
(
readme
.
name
,
readme
.
data
)
=
render
'projects/blob/viewer'
,
viewer:
readme
.
rich_viewer
,
viewer_url:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@ref
,
readme
.
path
),
viewer: :rich
,
format: :json
)
changelogs/unreleased/dm-async-tree-readme.yml
0 → 100644
View file @
00fc9f26
---
title
:
Load tree readme asynchronously
merge_request
:
author
:
features/project/project.feature
View file @
00fc9f26
...
@@ -18,6 +18,7 @@ Feature: Project
...
@@ -18,6 +18,7 @@ Feature: Project
Then
I should see the default project avatar
Then
I should see the default project avatar
And
I should not see the
"Remove avatar"
button
And
I should not see the
"Remove avatar"
button
@javascript
Scenario
:
I
should have readme on page
Scenario
:
I
should have readme on page
And
I visit project
"Shop"
page
And
I visit project
"Shop"
page
Then
I should see project
"Shop"
README
Then
I should see project
"Shop"
README
...
...
features/project/source/markdown_render.feature
View file @
00fc9f26
...
@@ -19,12 +19,14 @@ Feature: Project Source Markdown Render
...
@@ -19,12 +19,14 @@ Feature: Project Source Markdown Render
And
I click on Gitlab API in README
And
I click on Gitlab API in README
Then
I should see correct document rendered
Then
I should see correct document rendered
@javascript
Scenario
:
I
view README in markdown branch
Scenario
:
I
view README in markdown branch
Then
I should see files from repository in markdown
Then
I should see files from repository in markdown
And
I should see rendered README which contains correct links
And
I should see rendered README which contains correct links
And
I click on Rake tasks in README
And
I click on Rake tasks in README
Then
I should see correct directory rendered
Then
I should see correct directory rendered
@javascript
Scenario
:
I
view README in markdown branch to see reference links to directory
Scenario
:
I
view README in markdown branch to see reference links to directory
Then
I should see files from repository in markdown
Then
I should see files from repository in markdown
And
I should see rendered README which contains correct links
And
I should see rendered README which contains correct links
...
@@ -74,6 +76,7 @@ Feature: Project Source Markdown Render
...
@@ -74,6 +76,7 @@ Feature: Project Source Markdown Render
And
I click on Gitlab API in README
And
I click on Gitlab API in README
Then
I should see correct document rendered for markdown branch
Then
I should see correct document rendered for markdown branch
@javascript
Scenario
:
I
browse directory from markdown branch
Scenario
:
I
browse directory from markdown branch
When
I visit markdown branch
When
I visit markdown branch
Then
I should see files from repository in markdown branch
Then
I should see files from repository in markdown branch
...
...
features/steps/project/project.rb
View file @
00fc9f26
...
@@ -2,6 +2,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
...
@@ -2,6 +2,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
include
SharedAuthentication
include
SharedAuthentication
include
SharedProject
include
SharedProject
include
SharedPaths
include
SharedPaths
include
WaitForAjax
step
'change project settings'
do
step
'change project settings'
do
fill_in
'project_name_edit'
,
with:
'NewName'
fill_in
'project_name_edit'
,
with:
'NewName'
...
@@ -86,6 +87,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
...
@@ -86,6 +87,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
end
step
'I should see project "Shop" README'
do
step
'I should see project "Shop" README'
do
wait_for_ajax
page
.
within
(
'.readme-holder'
)
do
page
.
within
(
'.readme-holder'
)
do
expect
(
page
).
to
have_content
'testme'
expect
(
page
).
to
have_content
'testme'
end
end
...
...
features/steps/project/source/markdown_render.rb
View file @
00fc9f26
...
@@ -120,6 +120,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
...
@@ -120,6 +120,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
When
'I visit markdown branch'
do
When
'I visit markdown branch'
do
visit
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
"markdown"
)
visit
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
"markdown"
)
wait_for_ajax
end
end
When
'I visit markdown branch "README.md" blob'
do
When
'I visit markdown branch "README.md" blob'
do
...
...
spec/models/repository_spec.rb
View file @
00fc9f26
...
@@ -1634,7 +1634,7 @@ describe Repository, models: true do
...
@@ -1634,7 +1634,7 @@ describe Repository, models: true do
context
'with an existing repository'
do
context
'with an existing repository'
do
it
'returns the README'
do
it
'returns the README'
do
expect
(
repository
.
readme
).
to
be_an_instance_of
(
Gitlab
::
Git
::
Blob
)
expect
(
repository
.
readme
).
to
be_an_instance_of
(
Readme
Blob
)
end
end
end
end
end
end
...
...
spec/views/projects/tree/show.html.haml_spec.rb
View file @
00fc9f26
...
@@ -31,7 +31,7 @@ describe 'projects/tree/show' do
...
@@ -31,7 +31,7 @@ describe 'projects/tree/show' do
it
'displays correctly'
do
it
'displays correctly'
do
render
render
expect
(
rendered
).
to
have_css
(
'.js-project-refs-dropdown .dropdown-toggle-text'
,
text:
ref
)
expect
(
rendered
).
to
have_css
(
'.js-project-refs-dropdown .dropdown-toggle-text'
,
text:
ref
)
expect
(
rendered
).
to
have_css
(
'.readme-holder
.file-content'
,
text:
ref
)
expect
(
rendered
).
to
have_css
(
'.readme-holder
'
)
end
end
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