2020-06-11 11:08:36 -04:00
- form_classes = %w[wiki-form common-note-form prepend-top-default js-quick-submit]
2017-04-04 21:58:27 -04:00
2020-06-11 11:08:36 -04:00
- if @page.persisted?
- form_action = wiki_page_path(@wiki, @page)
- form_method = :put
- else
- form_action = wiki_path(@wiki, action: :create)
- form_method = :post
- form_classes << 'js-new-wiki-page'
= form_for @page, url: form_action, method: form_method,
2019-10-31 17:06:28 -04:00
html: { class: form_classes },
data: { uploads_path: uploads_path } do |f|
2020-03-02 13:07:42 -05:00
= form_errors(@page, truncate: :title)
2012-02-19 09:35:31 -05:00
2017-03-04 09:03:14 -05:00
- if @page.persisted?
2017-07-27 09:00:06 -04:00
= f.hidden_field :last_commit_sha, value: @page.last_commit_sha
2017-07-23 04:19:10 -04:00
2018-04-12 16:11:22 -04:00
.form-group.row
2017-07-23 04:19:10 -04:00
.col-sm-12= f.label :title, class: 'control-label-full-width'
2018-02-05 12:17:21 -05:00
.col-sm-12
2020-03-03 10:08:08 -05:00
= 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-08-01 01:54:52 -04:00
%span.d-inline-block.mw-100.prepend-top-5
= icon('lightbulb-o')
- if @page.persisted?
2018-02-05 12:17:21 -05:00
= s_("WikiEditPageTip|Tip: You can move this page by adding the path to the beginning of the title.")
2020-02-13 07:08:49 -05:00
= link_to icon('question-circle'), help_page_path('user/project/wiki/index', anchor: 'moving-a-wiki-page'),
target: '_blank', rel: 'noopener noreferrer'
2019-08-01 01:54:52 -04:00
- else
= s_("WikiNewPageTip|Tip: You can specify the full path for the new file. We will automatically create any missing directories.")
2020-02-13 07:08:49 -05:00
= 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-04-12 16:11:22 -04:00
.form-group.row
2017-06-12 07:47:46 -04:00
.col-sm-12= f.label :format, class: 'control-label-full-width'
.col-sm-12
2020-02-17 07:09:20 -05:00
.select-wrapper
2020-06-11 11:08:36 -04:00
= f.select :format, options_for_select(Wiki::MARKUPS, {selected: @page.format}), {}, class: 'form-control select-control'
2020-02-17 07:09:20 -05:00
= icon('chevron-down')
2014-01-01 15:44:30 -05:00
2018-04-12 16:11:22 -04:00
.form-group.row
2017-06-12 07:47:46 -04:00
.col-sm-12= f.label :content, class: 'control-label-full-width'
.col-sm-12
2020-06-11 11:08:36 -04:00
= render layout: 'shared/md_preview', locals: { url: wiki_page_path(@wiki, @page, action: :preview_markdown) } do
= render 'shared/zen', f: f, attr: :content, classes: 'note-textarea qa-wiki-content-textarea', placeholder: s_("WikiPage|Write your content or drag files here…")
2017-05-03 04:48:01 -04:00
= render 'shared/notes/hints'
2014-12-24 09:52:40 -05:00
2014-05-23 04:22:00 -04:00
.clearfix
.error-alert
2015-12-02 07:59:42 -05:00
2018-04-11 14:26:37 -04:00
.form-text.text-muted
2016-05-31 06:29:16 -04:00
= succeed '.' do
2020-03-05 10:07:52 -05:00
- 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-05-31 06:29:16 -04:00
= succeed '.' do
2017-09-27 13:13:29 -04:00
- 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-05-31 06:29:16 -04:00
2018-04-12 16:11:22 -04:00
.form-group.row
2017-06-12 07:47:46 -04:00
.col-sm-12= f.label :commit_message, class: 'control-label-full-width'
2019-08-01 01:54:52 -04:00
.col-sm-12= f.text_field :message, class: 'form-control qa-wiki-message-textbox', rows: 18, value: nil
2012-07-26 07:45:17 -04:00
2013-08-07 16:35:24 -04:00
.form-actions
2014-04-09 07:35:01 -04:00
- if @page && @page.persisted?
2019-01-29 15:56:34 -05:00
= f.submit _("Save changes"), class: 'btn-success btn qa-save-changes-button'
2018-04-09 13:42:45 -04:00
.float-right
2020-06-11 11:08:36 -04:00
= link_to _("Cancel"), wiki_page_path(@wiki, @page), class: 'btn btn-cancel btn-grouped'
2013-03-20 00:28:10 -04:00
- else
2019-07-26 17:48:11 -04:00
= f.submit s_("Wiki|Create page"), class: 'btn-success btn qa-create-page-button rspec-create-page-button'
2018-04-09 13:42:45 -04:00
.float-right
2020-06-11 11:08:36 -04:00
= link_to _("Cancel"), wiki_path(@wiki), class: 'btn btn-cancel'