documentation-editor 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/documentation_editor/pages.css.sass +3 -0
- data/app/controllers/documentation_editor/pages_controller.rb +3 -3
- data/app/models/documentation_editor/page.rb +10 -0
- data/app/models/documentation_editor/revision.rb +8 -0
- data/app/views/documentation_editor/pages/edit.html.haml +9 -9
- data/app/views/documentation_editor/pages/history.html.haml +3 -3
- data/app/views/documentation_editor/pages/index.html.haml +51 -31
- data/lib/documentation_editor/parser.rb +1 -1
- data/lib/documentation_editor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64861b09302704f3c7b7f0c55dc3d49145889b1b
|
4
|
+
data.tar.gz: 5608cade9583700de74092931b3981e87ce0ca02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1354ceb452217b3cfe0ea3a2a860272438383e94976f0d1d151d6df7d95d74a7f4f51e38199119258f45d906e7453dc339cd193b838a28c1b211baada99ff9f9
|
7
|
+
data.tar.gz: ff350a5d4650de4ec38e3862e04722f57592abd06af38e4649695f5cf670ad55316f33601fb79387ddbd906b7d4b2ba7e932f0b0bd1e81d0411166b1fc5a07be
|
@@ -32,11 +32,11 @@ module DocumentationEditor
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def update
|
35
|
-
@page.position = params[:page][:position]
|
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.
|
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.
|
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-
|
6
|
+
%a.btn.btn-default.btn-xs{href: admin_path}
|
7
7
|
%i.fa.fa-chevron-left
|
8
|
-
|
8
|
+
Home
|
9
9
|
%li
|
10
|
-
%a.btn.btn-default.btn-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
8
|
+
%a.btn.btn-default.btn-xs{href: admin_path}
|
9
9
|
%i.fa.fa-chevron-left
|
10
|
-
|
10
|
+
Home
|
11
11
|
%li
|
12
|
-
%a.btn.btn-default.btn-
|
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
|
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
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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-
|
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-
|
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-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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]
|
9
|
+
@language = options[:language]
|
10
10
|
super
|
11
11
|
@span_parsers.unshift(:block_tags)
|
12
12
|
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.
|
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-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|