2019-12-04 20:38:33 +05:30
- form_classes = 'wiki-form common-note-form prepend-top-default js-quick-submit'
- form_classes += ' js-new-wiki-page' unless @page.persisted?
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
= form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post,
2019-12-04 20:38:33 +05:30
html: { class: form_classes },
2019-03-02 22:35:43 +05:30
data: { uploads_path: uploads_path } do |f|
2020-04-08 14:13:33 +05:30
= form_errors(@page, truncate: :title)
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
- if @page.persisted?
= f.hidden_field :last_commit_sha, value: @page.last_commit_sha
2018-11-08 19:23:39 +05:30
.form-group.row
2017-09-10 17:25:29 +05:30
.col-sm-12= f.label :title, class: 'control-label-full-width'
2018-03-17 18:26:18 +05:30
.col-sm-12
2020-04-08 14:13:33 +05:30
= f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: s_('Wiki|Page title')
2019-12-04 20:38:33 +05:30
%span.d-inline-block.mw-100.prepend-top-5
= icon('lightbulb-o')
- if @page.persisted?
2018-03-17 18:26:18 +05:30
= s_("WikiEditPageTip|Tip: You can move this page by adding the path to the beginning of the title.")
2020-03-13 15:44:24 +05:30
= link_to icon('question-circle'), help_page_path('user/project/wiki/index', anchor: 'moving-a-wiki-page'),
target: '_blank', rel: 'noopener noreferrer'
2019-12-04 20:38:33 +05:30
- else
= s_("WikiNewPageTip|Tip: You can specify the full path for the new file. We will automatically create any missing directories.")
2020-03-13 15:44:24 +05:30
= succeed '.' do
= link_to _('Learn more'), help_page_path('user/project/wiki/index', anchor: 'creating-a-new-wiki-page'),
target: '_blank', rel: 'noopener noreferrer'
2018-11-08 19:23:39 +05:30
.form-group.row
2017-09-10 17:25:29 +05:30
.col-sm-12= f.label :format, class: 'control-label-full-width'
.col-sm-12
2020-03-13 15:44:24 +05:30
.select-wrapper
= f.select :format, options_for_select(ProjectWiki::MARKUPS, {selected: @page.format}), {}, class: 'form-control select-control'
= icon('chevron-down')
2014-09-02 18:07:02 +05:30
2018-11-08 19:23:39 +05:30
.form-group.row
2017-09-10 17:25:29 +05:30
.col-sm-12= f.label :content, class: 'control-label-full-width'
.col-sm-12
= render layout: 'projects/md_preview', locals: { url: project_wiki_preview_markdown_path(@project, @page.slug) } do
2019-03-02 22:35:43 +05:30
= render 'projects/zen', f: f, attr: :content, classes: 'note-textarea qa-wiki-content-textarea', placeholder: s_("WikiPage|Write your content or drag files here…")
2017-08-17 22:00:37 +05:30
= render 'shared/notes/hints'
2015-04-26 12:48:37 +05:30
2014-09-02 18:07:02 +05:30
.clearfix
.error-alert
2015-12-23 02:04:40 +05:30
2018-11-08 19:23:39 +05:30
.form-text.text-muted
2016-09-13 17:45:13 +05:30
= succeed '.' do
2020-04-08 14:13:33 +05:30
- case @page.format.to_s
- when 'rdoc'
- link_example = '{Link title}[link:page-slug]'
- when 'asciidoc'
- link_example = 'link:page-slug[Link title]'
- when 'org'
- link_example = '[[page-slug]]'
- else
- link_example = '[Link Title](page-slug)'
= (s_('WikiMarkdownTip|To link to a (new) page, simply type <code class="js-markup-link-example">%{link_example}</code>') % { link_example: link_example }).html_safe
2016-09-13 17:45:13 +05:30
= succeed '.' do
2018-03-17 18:26:18 +05:30
- markdown_link = link_to s_("WikiMarkdownDocs|documentation"), help_page_path('user/markdown', anchor: 'wiki-specific-markdown')
= (s_("WikiMarkdownDocs|More examples are in the %{docs_link}") % { docs_link: markdown_link }).html_safe
2016-09-13 17:45:13 +05:30
2018-11-08 19:23:39 +05:30
.form-group.row
2017-09-10 17:25:29 +05:30
.col-sm-12= f.label :commit_message, class: 'control-label-full-width'
2019-12-04 20:38:33 +05:30
.col-sm-12= f.text_field :message, class: 'form-control qa-wiki-message-textbox', rows: 18, value: nil
2014-09-02 18:07:02 +05:30
.form-actions
- if @page && @page.persisted?
2019-03-02 22:35:43 +05:30
= f.submit _("Save changes"), class: 'btn-success btn qa-save-changes-button'
2018-11-08 19:23:39 +05:30
.float-right
2018-03-17 18:26:18 +05:30
= link_to _("Cancel"), project_wiki_path(@project, @page), class: 'btn btn-cancel btn-grouped'
2014-09-02 18:07:02 +05:30
- else
2019-10-12 21:52:04 +05:30
= f.submit s_("Wiki|Create page"), class: 'btn-success btn qa-create-page-button rspec-create-page-button'
2018-11-08 19:23:39 +05:30
.float-right
2018-03-17 18:26:18 +05:30
= link_to _("Cancel"), project_wiki_path(@project, :home), class: 'btn btn-cancel'