Add specific markdown_preview route for Wikis
This commit is contained in:
parent
4a01b5e293
commit
b69f8a62b2
3 changed files with 20 additions and 1 deletions
|
@ -88,6 +88,20 @@ class Projects::WikisController < Projects::ApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
def markdown_preview
|
||||
text = params[:text]
|
||||
|
||||
ext = Gitlab::ReferenceExtractor.new(@project, current_user, current_user)
|
||||
ext.analyze(text)
|
||||
|
||||
render json: {
|
||||
body: view_context.markdown(text, pipeline: :wiki, project_wiki: @project_wiki),
|
||||
references: {
|
||||
users: ext.users.map(&:username)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def git_access
|
||||
end
|
||||
|
||||
|
|
|
@ -5,10 +5,14 @@
|
|||
|
||||
- content_for :scripts_body_top do
|
||||
- project = @target_project || @project
|
||||
- if @project_wiki
|
||||
- markdown_preview_path = namespace_project_wikis_markdown_preview_path(project.namespace, project)
|
||||
- else
|
||||
- markdown_preview_path = markdown_preview_namespace_project_path(project.namespace, project)
|
||||
- if current_user
|
||||
:javascript
|
||||
window.project_uploads_path = "#{namespace_project_uploads_path project.namespace,project}";
|
||||
window.markdown_preview_path = "#{markdown_preview_namespace_project_path(project.namespace, project)}";
|
||||
window.markdown_preview_path = "#{markdown_preview_path}";
|
||||
|
||||
- content_for :scripts_body do
|
||||
= render "layouts/init_auto_complete" if current_user
|
||||
|
|
|
@ -575,6 +575,7 @@ Rails.application.routes.draw do
|
|||
# Order matters to give priority to these matches
|
||||
get '/wikis/git_access', to: 'wikis#git_access'
|
||||
get '/wikis/pages', to: 'wikis#pages', as: 'wiki_pages'
|
||||
post '/wikis/markdown_preview', to:'wikis#markdown_preview'
|
||||
post '/wikis', to: 'wikis#create'
|
||||
|
||||
get '/wikis/*id/history', to: 'wikis#history', as: 'wiki_history', constraints: WIKI_SLUG_ID
|
||||
|
|
Loading…
Reference in a new issue