documentation-editor 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d8db49d46ea03aed0cf4ef19c9efa168153cfda
4
- data.tar.gz: bd00b630e7c9905c85424b731bddf19dafa6f04e
3
+ metadata.gz: 64861b09302704f3c7b7f0c55dc3d49145889b1b
4
+ data.tar.gz: 5608cade9583700de74092931b3981e87ce0ca02
5
5
  SHA512:
6
- metadata.gz: bb8c4efb42208c0a7a978f66a7e9dae2fe5c80c6f34d88501f61756133e16463d1fe5ed457c46f8d7c0e226fa820a2ebdfd17695487da56b011ff13a70a79c51
7
- data.tar.gz: 7254b3d293888ecde417416c03d2c8b7662b4f876516093f89a4093ab8be447f80a3dedffdb252d36be5f3bb83cd28e06d779ae1b3cc7b7478f920ab1c6417e3
6
+ metadata.gz: 1354ceb452217b3cfe0ea3a2a860272438383e94976f0d1d151d6df7d95d74a7f4f51e38199119258f45d906e7453dc339cd193b838a28c1b211baada99ff9f9
7
+ data.tar.gz: ff350a5d4650de4ec38e3862e04722f57592abd06af38e4649695f5cf670ad55316f33601fb79387ddbd906b7d4b2ba7e932f0b0bd1e81d0411166b1fc5a07be
@@ -4,6 +4,9 @@
4
4
  #documentation-editor
5
5
  position: relative
6
6
 
7
+ .nowrap
8
+ white-space: nowrap
9
+
7
10
  .editor-header
8
11
  background-color: white
9
12
  display: block
@@ -32,11 +32,11 @@ module DocumentationEditor
32
32
  end
33
33
 
34
34
  def update
35
- @page.position = params[:page][:position] || 0
35
+ @page.position = params[:page][:position] unless params[:page][:position].nil?
36
36
  @page.title = params[:page][:title] unless params[:page][:title].nil?
37
37
  @page.slug = params[:page][:slug] unless params[:page][:slug].nil?
38
38
  @page.description = params[:page][:description] unless params[:page][:description].nil?
39
- @page.languages = params[:page][:languages] unless params[:page][:languages].nil?
39
+ @page.languages_raw = params[:page][:languages_raw] unless params[:page][:languages_raw].nil?
40
40
  @page.section = params[:page][:section] unless params[:page][:section].nil?
41
41
  @page.save!
42
42
  render nothing: true
@@ -53,7 +53,7 @@ module DocumentationEditor
53
53
  p.title = params[:page][:title]
54
54
  p.slug = params[:page][:slug]
55
55
  p.description = params[:page][:description]
56
- p.languages = params[:page][:languages]
56
+ p.languages_raw = params[:page][:languages_raw]
57
57
  p.section = params[:page][:section]
58
58
  p.save!
59
59
  redirect_to edit_page_path(p)
@@ -8,6 +8,8 @@ module DocumentationEditor
8
8
 
9
9
  belongs_to :thumbnail, class_name: 'Image'
10
10
 
11
+ serialize :languages, Array
12
+
11
13
  after_create :add_first_revision
12
14
 
13
15
  def add_revision!(content, publish = false, author_id = nil)
@@ -26,6 +28,14 @@ module DocumentationEditor
26
28
  thumbnail.try(:image).try(:url)
27
29
  end
28
30
 
31
+ def languages_raw
32
+ self.languages.join(',')
33
+ end
34
+
35
+ def languages_raw=(v)
36
+ self.languages = v.to_s.split(/\s*,\s*/).reject { |x| x.blank? }
37
+ end
38
+
29
39
  private
30
40
  def add_first_revision
31
41
  r = Revision.new
@@ -3,6 +3,7 @@ module DocumentationEditor
3
3
  belongs_to :page
4
4
 
5
5
  def to_html(options = {})
6
+ options = defaulted(options)
6
7
  html = parse_document(options).to_html
7
8
  # resolve the variables
8
9
  html = resolve_variables(options, html)
@@ -15,6 +16,7 @@ module DocumentationEditor
15
16
  end
16
17
 
17
18
  def to_toc(options = {})
19
+ options = defaulted(options)
18
20
  roots = []
19
21
  levels = []
20
22
  h1 = nil
@@ -41,6 +43,7 @@ module DocumentationEditor
41
43
  end
42
44
 
43
45
  def section_title(options, section)
46
+ options = defaulted(options)
44
47
  doc = parse_document(options.merge(no_wrap: true))
45
48
  ids = id_generator(doc)
46
49
  doc.root.children.each do |child|
@@ -119,5 +122,10 @@ module DocumentationEditor
119
122
  end
120
123
  end
121
124
 
125
+ def defaulted(options)
126
+ options[:language] = options[:language] || options['language'] || (page && page.languages.first)
127
+ options
128
+ end
129
+
122
130
  end
123
131
  end
@@ -3,35 +3,35 @@
3
3
  .editor-header
4
4
  %ul.list-inline.pull-right
5
5
  %li
6
- %a.btn.btn-default.btn-sm{href: admin_path}
6
+ %a.btn.btn-default.btn-xs{href: admin_path}
7
7
  %i.fa.fa-chevron-left
8
- Back to Admin
8
+ Home
9
9
  %li
10
- %a.btn.btn-default.btn-sm{href: '#', 'ng-click' => 'save($event)', 'ng-disabled' => '!diff()'}
10
+ %a.btn.btn-default.btn-xs{href: '#', 'ng-click' => 'save($event)', 'ng-disabled' => '!diff()'}
11
11
  %i.fa.fa-save
12
12
  Save
13
13
  %li
14
- %a.btn.btn-success.btn-sm{href: '#', 'ng-click' => 'preview($event)'}
14
+ %a.btn.btn-success.btn-xs{href: '#', 'ng-click' => 'preview($event)'}
15
15
  %i.fa.fa-eye
16
16
  Save & Preview
17
17
  %li
18
- %a.btn.btn-danger.btn-sm{href: '#', 'ng-click' => 'publish($event)', 'ng-disabled' => 'published_revision_id === last_revision_id'}
18
+ %a.btn.btn-danger.btn-xs{href: '#', 'ng-click' => 'publish($event)', 'ng-disabled' => 'published_revision_id === last_revision_id'}
19
19
  %i.fa.fa-save
20
20
  Save & Publish
21
21
  %li
22
- %a.btn.btn-default.btn-sm{href: '#', 'ng-click' => 'toggleView($event)'}
22
+ %a.btn.btn-default.btn-xs{href: '#', 'ng-click' => 'toggleView($event)'}
23
23
  %i.fa.fa-arrows-h
24
24
  Switch View
25
25
  %li
26
- %a.btn.btn-default.btn-sm{href: '#', 'data-toggle' => 'modal', "data-target" => "#upload-thumbnail"}
26
+ %a.btn.btn-default.btn-xs{href: '#', 'data-toggle' => 'modal', "data-target" => "#upload-thumbnail"}
27
27
  %i.fa.fa-upload
28
28
  Thumbnail
29
29
  %li
30
- %a.btn.btn-default.btn-sm{href: history_path(@page)}
30
+ %a.btn.btn-default.btn-xs{href: history_path(@page)}
31
31
  %i.fa.fa-history
32
32
  History
33
33
  %li
34
- %a.btn.btn-warning.btn-sm{href: '#', 'ng-click' => 'undo($event)', 'ng-disabled' => 'undoRedo.length === 0'}
34
+ %a.btn.btn-warning.btn-xs{href: '#', 'ng-click' => 'undo($event)', 'ng-disabled' => 'undoRedo.length === 0'}
35
35
  %i.fa.fa-undo
36
36
  Undo
37
37
  %h1
@@ -5,11 +5,11 @@
5
5
  .editor-header
6
6
  %ul.list-inline.pull-right
7
7
  %li
8
- %a.btn.btn-default.btn-sm{href: admin_path}
8
+ %a.btn.btn-default.btn-xs{href: admin_path}
9
9
  %i.fa.fa-chevron-left
10
- Back to Admin
10
+ Home
11
11
  %li
12
- %a.btn.btn-default.btn-sm{href: edit_page_path(@page)}
12
+ %a.btn.btn-default.btn-xs{href: edit_page_path(@page)}
13
13
  %i.fa.fa-edit
14
14
  Edit
15
15
  %h1
@@ -3,20 +3,18 @@
3
3
  %h1 Edit documentation
4
4
 
5
5
  .editor-content
6
+ = link_to '#', class: 'btn btn-success pull-right', onclick: '$("#modal-new-page").modal("show"); return false;' do
7
+ %i.fa.fa-plus-circle
8
+ Add a new page
6
9
  %h3 Pages
7
10
  %table.table.table-striped.pages
8
11
  %thead
9
12
  %tr
10
13
  %th Thumbnail
11
- %th Position
12
- %th Title
13
- %th Slug
14
- %th Description
15
- %th Languages
16
- %th Section
17
- %th Last modification
18
- %th Published at
19
- %th Published by
14
+ %th.nowrap Position
15
+ %th.nowrap Title
16
+ %th.nowrap Slug
17
+ %th Metadata
20
18
  %th.text-right Actions
21
19
  %tbody
22
20
  - DocumentationEditor::Page.order('position ASC').each do |p|
@@ -24,33 +22,55 @@
24
22
  %td
25
23
  - if p.thumbnail
26
24
  = image_tag p.thumbnail_url
27
- %td= best_in_place p, :position, url: update_path(p)
28
- %td= best_in_place p, :title, url: update_path(p)
29
- %td= best_in_place p, :slug, url: update_path(p)
30
- %td= best_in_place p, :description, url: update_path(p)
31
- %td= best_in_place p, :languages, url: update_path(p)
32
- %td= best_in_place p, :section, url: update_path(p)
33
- %td= l p.created_at, format: :short
34
- %td= p.published_revision ? l(p.published_revision.created_at, format: :long) : ''
35
- %td= p.published_revision ? p.published_revision.author_id : ''
36
- %td.text-right
37
- = link_to edit_page_path(p), class: 'btn btn-default btn-sm' do
25
+ %td.nowrap= best_in_place p, :position, url: update_path(p)
26
+ %td.nowrap= best_in_place p, :title, url: update_path(p)
27
+ %td.nowrap= best_in_place p, :slug, url: update_path(p)
28
+ %td
29
+ %ul.list-unstyled
30
+ %li
31
+ %strong Description:
32
+ = best_in_place p, :description, url: update_path(p)
33
+ %li
34
+ %strong Languages:
35
+ = best_in_place p, :languages_raw, url: update_path(p)
36
+ %li
37
+ %strong Section:
38
+ = best_in_place p, :section, url: update_path(p)
39
+ %li
40
+ %strong Last modification:
41
+ = l p.created_at, format: :short
42
+ %li
43
+ %strong Published at:
44
+ = p.published_revision ? l(p.published_revision.created_at, format: :long) : ''
45
+ %li
46
+ %strong Published by:
47
+ = p.published_revision ? p.published_revision.author_id : ''
48
+ %td.text-right.nowrap
49
+ = link_to edit_page_path(p), class: 'btn btn-default btn-xs' do
38
50
  %i.fa.fa-edit
39
51
  Edit
40
- = link_to preview_page_path(p), class: 'btn btn-default btn-sm' do
52
+ = link_to preview_page_path(p), class: 'btn btn-default btn-xs' do
41
53
  %i.fa.fa-eye
42
54
  Preview
43
- = link_to history_path(p), class: 'btn btn-default btn-sm' do
55
+ = link_to history_path(p), class: 'btn btn-default btn-xs' do
44
56
  %i.fa.fa-history
45
57
  History
46
- = link_to delete_page_path(p), class: 'btn btn-danger btn-sm', data: { confirm: 'Are you sure you want to delete this page?', method: :delete } do
58
+ = link_to delete_page_path(p), class: 'btn btn-danger btn-xs', data: { confirm: 'Are you sure you want to delete this page?', method: :delete } do
47
59
  %i.fa.fa-trash
48
60
  Delete
49
- %h3 Create a new page
50
- = form_for DocumentationEditor::Page.new, url: admin_path, html: { class: 'form form-inline' } do |f|
51
- = f.text_field :title, placeholder: 'Title', class: 'form-control'
52
- = f.text_field :slug, placeholder: 'tutorials/my-tutorial', class: 'form-control'
53
- = f.text_field :description, placeholder: 'Description', class: 'form-control'
54
- = f.text_field :languages, placeholder: 'ruby, php, python', class: 'form-control'
55
- = f.text_field :section, placeholder: 'getting-started', class: 'form-control'
56
- = f.submit 'Create', class: 'btn btn-success'
61
+
62
+ .modal.fade#modal-new-page
63
+ .modal-dialog
64
+ .modal-content
65
+ .modal-header
66
+ %button.close{type: 'button', 'data-dismiss' => 'modal', 'aria-label' => 'Close'}
67
+ %span{'aria-hidden' => true} ×
68
+ %h4.modal-title Create a new page
69
+ .modal-body
70
+ = form_for DocumentationEditor::Page.new, url: admin_path, html: { class: 'form' } do |f|
71
+ %p= f.text_field :title, placeholder: 'Title', class: 'form-control'
72
+ %p= f.text_field :slug, placeholder: 'Slug (ex: tutorials/my-tutorial)', class: 'form-control'
73
+ %p= f.text_field :description, placeholder: 'Description', class: 'form-control'
74
+ %p= f.text_field :languages_raw, placeholder: 'Languages (ex: ruby, php, python)', class: 'form-control'
75
+ %p= f.text_field :section, placeholder: 'Section name (ex: getting-started)', class: 'form-control'
76
+ %p.text-center= f.submit 'Create', class: 'btn btn-success'
@@ -6,7 +6,7 @@ require 'htmlentities'
6
6
  class Kramdown::Parser::BlockKramdown < Kramdown::Parser::Kramdown
7
7
 
8
8
  def initialize(source, options)
9
- @language = options[:language] || options['language']
9
+ @language = options[:language]
10
10
  super
11
11
  @span_parsers.unshift(:block_tags)
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module DocumentationEditor
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentation-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails