summaryrefslogtreecommitdiff
path: root/app/views/projects/wikis/_form.html.haml
blob: e5a1fccf9ba00ffa1e47b79d3f316fe3a44cea64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
- commit_message = @page.persisted? ? "Update #{@page.title}" : "Create #{@page.title}"

= form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post, html: { class: 'form-horizontal wiki-form common-note-form prepend-top-default js-quick-submit' } do |f|
  = form_errors(@page)

  - if @page.persisted?
    = f.hidden_field :last_commit_sha, value: @page.last_commit_sha

  .form-group
    .col-sm-12= f.label :title, class: 'control-label-full-width'
    .col-sm-12= f.text_field :title, class: 'form-control', value: @page.title
  .form-group
    .col-sm-12= f.label :format, class: 'control-label-full-width'
    .col-sm-12
      = f.select :format, options_for_select(ProjectWiki::MARKUPS, {selected: @page.format}), {}, class: "form-control"

  .form-group
    .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
        = render 'projects/zen', f: f, attr: :content, classes: 'note-textarea', placeholder: 'Write your content or drag files here...'
        = render 'shared/notes/hints'

      .clearfix
      .error-alert

      .help-block
        = succeed '.' do
          To link to a (new) page, simply type
          %code [Link Title](page-slug)

        = succeed '.' do
          More examples are in the
          = link_to 'documentation', help_page_path("user/markdown", anchor: "wiki-specific-markdown")

  .form-group
    .col-sm-12= f.label :commit_message, class: 'control-label-full-width'
    .col-sm-12= f.text_field :message, class: 'form-control', rows: 18, value: commit_message

  .form-actions
    - if @page && @page.persisted?
      = f.submit 'Save changes', class: "btn-save btn"
      .pull-right
        = link_to "Cancel", project_wiki_path(@project, @page), class: "btn btn-cancel btn-grouped"
    - else
      = f.submit 'Create page', class: "btn-create btn"
      .pull-right
        = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel"