hyde_admin 0.0.1 → 0.0.3
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/.gitattributes +3 -0
- data/.idea/hyde_admin.iml +2 -0
- data/.idea/vcs.xml +6 -0
- data/CHANGELOG.md +11 -0
- data/README.md +23 -0
- data/TODO.md +1 -0
- data/bin/admin_views/admin_layout.html.erb +138 -109
- data/bin/admin_views/configuration.erb +13 -0
- data/bin/admin_views/dashboard.erb +1 -1
- data/bin/admin_views/editor_html.erb +24 -0
- data/bin/admin_views/editor_js.erb +120 -0
- data/bin/admin_views/files/edit.erb +30 -0
- data/bin/admin_views/files/listing.erb +111 -0
- data/bin/admin_views/posts/edit.erb +156 -0
- data/bin/admin_views/posts/listing.erb +34 -0
- data/bin/fslightbox/fslightbox.js +1 -0
- data/bin/hyde_admin +3 -0
- data/bin/hyde_admin.ru +243 -55
- data/bin/hyde_admin.yml +12 -5
- data/bin/hyde_assets/hyde_admin.css +18 -0
- data/bin/hyde_assets/hyde_admin.js +24 -0
- data/bin/i18n/en.yml +62 -1
- data/bin/i18n/fr.yml +62 -1
- data/bin/lib/codemirror.css +349 -0
- data/bin/lib/codemirror.js +9833 -0
- data/bin/mode/css/css.js +864 -0
- data/bin/mode/css/gss.html +104 -0
- data/bin/mode/css/gss_test.js +17 -0
- data/bin/mode/css/index.html +81 -0
- data/bin/mode/css/less.html +152 -0
- data/bin/mode/css/less_test.js +54 -0
- data/bin/mode/css/scss.html +158 -0
- data/bin/mode/css/scss_test.js +110 -0
- data/bin/mode/css/test.js +217 -0
- data/bin/mode/htmlembedded/htmlembedded.js +37 -0
- data/bin/mode/htmlembedded/index.html +60 -0
- data/bin/mode/htmlmixed/htmlmixed.js +153 -0
- data/bin/mode/htmlmixed/index.html +100 -0
- data/bin/mode/javascript/index.html +118 -0
- data/bin/mode/javascript/javascript.js +959 -0
- data/bin/mode/javascript/json-ld.html +72 -0
- data/bin/mode/javascript/test.js +521 -0
- data/bin/mode/javascript/typescript.html +62 -0
- data/bin/mode/markdown/index.html +418 -0
- data/bin/mode/markdown/markdown.js +886 -0
- data/bin/mode/markdown/test.js +1319 -0
- data/bin/mode/ruby/index.html +183 -0
- data/bin/mode/ruby/ruby.js +303 -0
- data/bin/mode/ruby/test.js +23 -0
- data/bin/mode/sass/index.html +68 -0
- data/bin/mode/sass/sass.js +459 -0
- data/bin/mode/sass/test.js +122 -0
- data/bin/mode/spreadsheet/index.html +42 -0
- data/bin/mode/spreadsheet/spreadsheet.js +112 -0
- data/bin/mode/xml/index.html +61 -0
- data/bin/mode/xml/test.js +51 -0
- data/bin/mode/xml/xml.js +417 -0
- data/bin/mode/yaml/index.html +80 -0
- data/bin/mode/yaml/yaml.js +120 -0
- data/bin/mode/yaml-frontmatter/index.html +121 -0
- data/bin/mode/yaml-frontmatter/yaml-frontmatter.js +72 -0
- data/hyde_admin.gemspec +6 -1
- data/lib/hyde_admin/version.rb +1 -1
- metadata +114 -7
- data/bin/admin_views/edit.erb +0 -57
- data/bin/admin_views/listing.erb +0 -32
- data/bin/hyde_admin.sh +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a05ad4bb0704e1175cd5ed0393ae09181a0241dd423add001cd7ef4cc365ed2
|
4
|
+
data.tar.gz: 1db71be2ffc12226a0c10fb66751311e4bd6b8d795aa3bccf4dcc9da5993e557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0902597c60ffe712e999a065655ad6034f3d9e2b62f129b815e2139ef684d0f565f08d0fda4ad2f59b85a182da93f0d730dcfbad99128521befe593d266cd21e'
|
7
|
+
data.tar.gz: 8926be4affe34325d115ccf1788609fc46a7770a770233944a425a2a054870b501861601eaf232ab73f2ac48741068b611ec59e3535035010513917b3c9d857d
|
data/.gitattributes
ADDED
data/.idea/hyde_admin.iml
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
</content>
|
12
12
|
<orderEntry type="inheritedJdk" />
|
13
13
|
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, RVM: ruby-2.7.0) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.10, RVM: ruby-2.7.0) [gem]" level="application" />
|
14
16
|
</component>
|
15
17
|
<component name="RModuleSettingsStorage">
|
16
18
|
<LOAD_PATH number="0" />
|
data/.idea/vcs.xml
ADDED
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## Getting Started with Hyde Admin
|
2
|
+
|
3
|
+
Add
|
4
|
+
|
5
|
+
`gem 'hyde_admin'`
|
6
|
+
|
7
|
+
In the Gemfile of your jekyll site.
|
8
|
+
|
9
|
+
Run
|
10
|
+
|
11
|
+
`bundle update`
|
12
|
+
|
13
|
+
When run
|
14
|
+
|
15
|
+
`hyde_admin`
|
16
|
+
|
17
|
+
in your jekyll directory.
|
18
|
+
You can visit localhost:9292 !
|
19
|
+
|
20
|
+
hyde_admin.yml is automatically generated in your jekyll directory.
|
21
|
+
(you can change settings with hyde_admin ou directly)
|
22
|
+
|
23
|
+
Hyde_admin allow ssh deployment.
|
data/TODO.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Overview btn for posts/drafts/pages (save && rebuild && open in new tab)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html lang="
|
2
|
+
<html lang="<%= @hyde_parameters['hyde_admin_language'] %>">
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<title>Hyde for Jekyll</title>
|
@@ -11,121 +11,150 @@
|
|
11
11
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
|
12
12
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
|
13
13
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
14
|
-
|
14
|
+
|
15
|
+
<script src="/lib/codemirror.js"></script>
|
16
|
+
<link rel="stylesheet" href="/lib/codemirror.css">
|
17
|
+
<script src="/mode/javascript/javascript.js"></script>
|
18
|
+
<script src="/mode/css/css.js"></script>
|
19
|
+
<script src="/mode/sass/sass.js"></script>
|
20
|
+
<script src="/mode/ruby/ruby.js"></script>
|
21
|
+
<script src="/mode/yaml/yaml.js"></script>
|
22
|
+
<script src="/mode/xml/xml.js"></script>
|
23
|
+
<script src="/mode/markdown/markdown.js"></script>
|
24
|
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
25
|
+
|
26
|
+
<link rel="stylesheet" href="/hyde_assets/hyde_admin.css">
|
27
|
+
<script src="/hyde_assets/hyde_admin.js"></script>
|
15
28
|
</head>
|
16
29
|
<body>
|
17
|
-
|
18
|
-
<div class="
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
<
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
<
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
</a>
|
104
|
-
</li>
|
105
|
-
</ul>
|
106
|
-
-->
|
30
|
+
<div class="container-fluid">
|
31
|
+
<div class="row">
|
32
|
+
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
33
|
+
<div class="position-sticky pt-3">
|
34
|
+
<ul class="nav flex-column">
|
35
|
+
<li class="nav-item">
|
36
|
+
<a class="nav-link active" aria-current="page" href="/<%= @hyde_parameters['site_index'] %>">
|
37
|
+
<span data-feather="home" class="fas fa-eye"></span>
|
38
|
+
<%= t.overview.capitalize %>
|
39
|
+
</a>
|
40
|
+
</li>
|
41
|
+
<li class="nav-item">
|
42
|
+
</li>
|
43
|
+
<li class="nav-item">
|
44
|
+
<a class="nav-link active" aria-current="page" href="/dashboard">
|
45
|
+
<span data-feather="home" class="fas fa-tachometer-alt"></span>
|
46
|
+
<%= t.dashboard.capitalize %>
|
47
|
+
</a>
|
48
|
+
</li>
|
49
|
+
<li class="nav-item">
|
50
|
+
<a class="nav-link" href="/pages/index">
|
51
|
+
<span data-feather="file" class="fas fa-file"></span>
|
52
|
+
<%= t.pages.capitalize %>
|
53
|
+
</a>
|
54
|
+
</li>
|
55
|
+
<li class="nav-item">
|
56
|
+
<a class="nav-link" href="/drafts/index">
|
57
|
+
<span data-feather="shopping-cart" class="fas fa-file"></span>
|
58
|
+
<%= t.drafts.capitalize %>
|
59
|
+
</a>
|
60
|
+
</li>
|
61
|
+
<li class="nav-item">
|
62
|
+
<a class="nav-link" href="/posts/index">
|
63
|
+
<span data-feather="users" class="fas fa-file"></span>
|
64
|
+
<%= t.posts.capitalize %>
|
65
|
+
</a>
|
66
|
+
</li>
|
67
|
+
<li class="nav-item"></li>
|
68
|
+
<li class="nav-item">
|
69
|
+
<a class="nav-link" href="/files/index">
|
70
|
+
<span data-feather="users" class="fas fa-copy"></span>
|
71
|
+
<%= t.files.capitalize %>
|
72
|
+
</a>
|
73
|
+
</li>
|
74
|
+
<li class="nav-item"></li>
|
75
|
+
<li class="nav-item">
|
76
|
+
<a class="nav-link active" aria-current="page" href="/rebuild" id="btn-rebuild">
|
77
|
+
<span data-feather="home" class="fas fa-hammer"></span>
|
78
|
+
<%= t.rebuild.capitalize %>
|
79
|
+
</a>
|
80
|
+
</li>
|
81
|
+
<li class="nav-item">
|
82
|
+
<a class="nav-link active" aria-current="page" href="/deploy" id="btn-deploy">
|
83
|
+
<span data-feather="home" class="fas fa-cloud-upload-alt"></span>
|
84
|
+
<%= t.deploy.capitalize %>
|
85
|
+
</a>
|
86
|
+
</li>
|
87
|
+
<li class="nav-item"></li>
|
88
|
+
<li class="nav-item">
|
89
|
+
<a class="nav-link" href="/configuration">
|
90
|
+
<span data-feather="layers" class="fas fa-tools"></span>
|
91
|
+
<%= t.configuration.capitalize %>
|
92
|
+
</a>
|
93
|
+
</li>
|
94
|
+
</ul>
|
95
|
+
<p class="text-center text-muted"><br><br><em>Hyde Admin V.<%= HydeAdmin::VERSION %></em> <a href="https://github.com/rivsc/hyde_admin" class="link-secondary"><i class="fab fa-github"></i></a></p>
|
96
|
+
</div>
|
97
|
+
</nav>
|
98
|
+
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
99
|
+
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
100
|
+
<h1 class="h2">Hyde Admin for Jekyll</h1>
|
101
|
+
<!--
|
102
|
+
<div class="btn-toolbar mb-2 mb-md-0">
|
103
|
+
<div class="btn-group me-2">
|
104
|
+
<button type="button" class="btn btn-sm btn-outline-secondary"><%= t.backup_zip %></button>
|
105
|
+
<button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
|
106
|
+
</div>
|
107
|
+
<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
|
108
|
+
<span data-feather="calendar"></span>
|
109
|
+
This week
|
110
|
+
</button>
|
111
|
+
</div>
|
112
|
+
-->
|
113
|
+
</div>
|
114
|
+
<%= yield %>
|
115
|
+
</main>
|
107
116
|
</div>
|
108
|
-
</
|
117
|
+
</div>
|
118
|
+
|
119
|
+
<div id="waiting" style="width:100vw;height:100vh;display:none;text-align:center;background-color:rgba(0,0,0,0.5);position: fixed;top:0px;left:0px">
|
120
|
+
<i class="fas fa-circle-notch fa-10x fa-spin" style="margin-top:40vh;"></i>
|
121
|
+
</div>
|
109
122
|
|
110
|
-
<
|
111
|
-
<div class="
|
112
|
-
<
|
113
|
-
|
114
|
-
|
115
|
-
<button type="button" class="
|
116
|
-
|
123
|
+
<div class="modal modal-image" tabindex="-1" role="dialog">
|
124
|
+
<div class="modal-dialog" role="document">
|
125
|
+
<div class="modal-content">
|
126
|
+
<div class="modal-header">
|
127
|
+
<h5 class="modal-title">Images</h5>
|
128
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
129
|
+
<span aria-hidden="true">×</span>
|
130
|
+
</button>
|
131
|
+
</div>
|
132
|
+
<div class="modal-body modal-body-image">
|
133
|
+
<% path_of_images = File.join(Dir.pwd, @hyde_parameters['images_path'], "**") %>
|
134
|
+
<% $stderr.puts(path_of_images) %>
|
135
|
+
<% Dir.glob(path_of_images)[(@page || 0) * 9, ((@page || 0) + 1) * 9 ].each do |img| %>
|
136
|
+
<% img = img.gsub(Dir.pwd, "") %>
|
137
|
+
<div class="image-element">
|
138
|
+
<img src="<%= img %>" alt="<%= img %>">
|
139
|
+
</div>
|
140
|
+
<% end %>
|
117
141
|
</div>
|
118
|
-
<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
|
119
|
-
<span data-feather="calendar"></span>
|
120
|
-
This week
|
121
|
-
</button>
|
122
142
|
</div>
|
123
143
|
</div>
|
124
|
-
|
125
|
-
|
126
|
-
</main>
|
127
|
-
</div>
|
128
|
-
</div>
|
144
|
+
</div>
|
129
145
|
|
146
|
+
<script type="text/javascript" charset="utf-8">
|
147
|
+
<% if @file %>
|
148
|
+
if(window.document.getElementById('i-content')){
|
149
|
+
window.myCodeMirror = CodeMirror.fromTextArea(window.document.getElementById('i-content'), {
|
150
|
+
lineNumbers: true,
|
151
|
+
tabSize: 2,
|
152
|
+
indentWithTabs: false,
|
153
|
+
mode: "<%= {'.js' => 'javascript', '.json' => 'javascript', '.xml' => 'xml', '.svg' => 'xml', '.css' => 'css', '.yml' => 'yaml', '.sass' => 'sass', '.rb' => 'ruby', '.md' => 'markdown'}[File.extname(@file)] || 'markdown' %>"
|
154
|
+
});
|
155
|
+
}
|
156
|
+
<% end %>
|
157
|
+
</script>
|
158
|
+
<script src="/fslightbox/fslightbox.js"></script>
|
130
159
|
</body>
|
131
160
|
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h2><%= t.configuration.capitalize %></h2>
|
2
|
+
|
3
|
+
<form action="/configuration" method="post">
|
4
|
+
<% @hyde_parameters.each_pair do |setting, value| %>
|
5
|
+
<div class="mb-3">
|
6
|
+
<label for="i-<%= setting %>" class="form-label"><%= t.send(setting).capitalize %></label>
|
7
|
+
<input type="text" class="form-control" value="<%= value %>" name="<%= setting %>" id="i-<%= setting %>">
|
8
|
+
<div id="i-<%= setting %>-help" class="form-text"><%= t.send("help_#{setting}").capitalize %></div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
<button type="submit" class="btn btn-primary"><%= t.submit.capitalize %></button>
|
12
|
+
</form>
|
13
|
+
|
@@ -1 +1 @@
|
|
1
|
-
dashboard
|
1
|
+
<h2><%= t.dashboard.capitalize %></h2>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="codemirror-toolbar btn-toolbar" role="toolbar">
|
2
|
+
<div class="btn-group mr-2" role="group" aria-label="Undo/redo">
|
3
|
+
<button type="button" class="btn btn-light"><i class="fas fa-undo-alt" title="<%= t.editor_undo %>"></i></button>
|
4
|
+
<button type="button" class="btn btn-light"><i class="fas fa-redo-alt" title="<%= t.editor_redo %>"></i></button>
|
5
|
+
</div>
|
6
|
+
<div class="btn-group mr-2" role="group" aria-label="Structural tags">
|
7
|
+
<button type="button" class="btn btn-light"><i class="fas fa-file-image" title="<%= t.editor_file %>"></i></button>
|
8
|
+
<button type="button" class="btn btn-light"><i class="fas fa-list cmt-replace" title="<%= t.editor_list %>"></i></button>
|
9
|
+
<button type="button" class="btn btn-light"><i class="fas fa-list-ol cmt-replace" title="<%= t.editor_list_ol %>"></i></button>
|
10
|
+
<button type="button" class="btn btn-light"><i class="fas fa-link cmt-replace" title="<%= t.editor_link %>"></i></button>
|
11
|
+
<button type="button" class="btn btn-light"><i class="fas fa-quote-left cmt-replace" title="<%= t.editor_quote %>"></i></button>
|
12
|
+
</div>
|
13
|
+
<div class="btn-group mr-2" role="group" aria-label="Style tags">
|
14
|
+
<button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-1" title="<%= t.editor_title_h1 %>">1</i></button>
|
15
|
+
<button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-2" title="<%= t.editor_title_h2 %>">2</i></button>
|
16
|
+
<button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-3" title="<%= t.editor_title_h3 %>">3</i></button>
|
17
|
+
<button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-4" title="<%= t.editor_title_h4 %>">4</i></button>
|
18
|
+
<button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-5" title="<%= t.editor_title_h5 %>">5</i></button>
|
19
|
+
<button type="button" class="btn btn-light"><i class="fas fa-underline cmt-replace" title="<%= t.editor_underline %>"></i></button>
|
20
|
+
<button type="button" class="btn btn-light"><i class="fas fa-bold cmt-replace" title="<%= t.editor_bold %>"></i></button>
|
21
|
+
<button type="button" class="btn btn-light"><i class="fas fa-italic cmt-replace" title="<%= t.editor_italic %>"></i></button>
|
22
|
+
<button type="button" class="btn btn-light"><i class="fas fa-strikethrough cmt-replace" title="<%= t.editor_strikethrough %>"></i></button>
|
23
|
+
</div>
|
24
|
+
</div>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
$(document).on('click', '.codemirror-toolbar .fa-undo-alt', function(){
|
2
|
+
window.myCodeMirror.undo();
|
3
|
+
});
|
4
|
+
$(document).on('click', '.codemirror-toolbar .fa-redo-alt', function(){
|
5
|
+
window.myCodeMirror.redo();
|
6
|
+
});
|
7
|
+
$(document).on('click', '.codemirror-toolbar .fa-file-image', function(){
|
8
|
+
$('.modal-image').modal('show');
|
9
|
+
});
|
10
|
+
$(document).on('click', '.modal-image img', function(){
|
11
|
+
let img_src = '<img src="' + $(this).attr('src') + '" alt="<%= t.default_alt_img %>" title="<%= t.default_title_img %>" />';
|
12
|
+
if(window.mode_markdown){
|
13
|
+
img_src = '.attr('src') + ')';
|
14
|
+
}
|
15
|
+
window.myCodeMirror.replaceSelection(img_src);
|
16
|
+
$('.modal-image').modal('hide');
|
17
|
+
});
|
18
|
+
$(document).on('click', '.codemirror-toolbar .fa-heading', function(){
|
19
|
+
let obj_cursor = window.myCodeMirror.getCursor();
|
20
|
+
|
21
|
+
let heading_number = 0;
|
22
|
+
if($(this).hasClass('cmt-heading-1')){
|
23
|
+
heading_number = 1;
|
24
|
+
}else if($(this).hasClass('cmt-heading-2')){
|
25
|
+
heading_number = 2;
|
26
|
+
}else if($(this).hasClass('cmt-heading-3')){
|
27
|
+
heading_number = 3;
|
28
|
+
}else if($(this).hasClass('cmt-heading-4')){
|
29
|
+
heading_number = 4;
|
30
|
+
}else if($(this).hasClass('cmt-heading-5')){
|
31
|
+
heading_number = 5;
|
32
|
+
}
|
33
|
+
|
34
|
+
let begin_str = '<h' + heading_number + '>';
|
35
|
+
let end_str = '</h' + heading_number + '>';
|
36
|
+
if(window.mode_markdown){
|
37
|
+
begin_str = '#';
|
38
|
+
for (let i = 1; i < heading_number; i++) {
|
39
|
+
begin_str = begin_str + '#';
|
40
|
+
}
|
41
|
+
begin_str = begin_str + ' ';
|
42
|
+
end_str = '';
|
43
|
+
}
|
44
|
+
window.myCodeMirror.replaceSelection(begin_str + window.myCodeMirror.getSelection() + end_str);
|
45
|
+
if(!window.myCodeMirror.somethingSelected()){
|
46
|
+
window.myCodeMirror.setCursor({ line: obj_cursor.line, ch: obj_cursor.ch + begin_str.length });
|
47
|
+
}
|
48
|
+
window.myCodeMirror.focus();
|
49
|
+
});
|
50
|
+
$(document).on('click', '.codemirror-toolbar .cmt-replace', function(){
|
51
|
+
let begin_str = '';
|
52
|
+
let end_str = '';
|
53
|
+
|
54
|
+
if($(this).hasClass('fa-underline')){
|
55
|
+
begin_str = '<u>';
|
56
|
+
end_str = '</u>';
|
57
|
+
/*if(window.mode_markdown){
|
58
|
+
begin_str = '';
|
59
|
+
end_str = '';
|
60
|
+
}*/
|
61
|
+
}else if($(this).hasClass('fa-bold')){
|
62
|
+
begin_str = '<b>';
|
63
|
+
end_str = '</b>';
|
64
|
+
if(window.mode_markdown){
|
65
|
+
begin_str = '**';
|
66
|
+
end_str = '**';
|
67
|
+
}
|
68
|
+
}else if($(this).hasClass('fa-italic')){
|
69
|
+
begin_str = '<i>';
|
70
|
+
end_str = '</i>';
|
71
|
+
if(window.mode_markdown){
|
72
|
+
begin_str = '*';
|
73
|
+
end_str = '*';
|
74
|
+
}
|
75
|
+
}else if($(this).hasClass('fa-strikethrough')){
|
76
|
+
begin_str = '<s>';
|
77
|
+
end_str = '</s>';
|
78
|
+
if(window.mode_markdown){
|
79
|
+
begin_str = '~~';
|
80
|
+
end_str = '~~';
|
81
|
+
}
|
82
|
+
}else if($(this).hasClass('fa-link')){
|
83
|
+
begin_str = '<a href="https://www.example.com/">';
|
84
|
+
end_str = '</a>';
|
85
|
+
if(window.mode_markdown){
|
86
|
+
begin_str = '[';
|
87
|
+
end_str = '](https://www.example.com/)';
|
88
|
+
}
|
89
|
+
}else if($(this).hasClass('fa-quote-left')){
|
90
|
+
begin_str = '<blockquote>\n <p>';
|
91
|
+
end_str = '</p>\n</blockquote>';
|
92
|
+
if(window.mode_markdown){
|
93
|
+
begin_str = '>';
|
94
|
+
end_str = '';
|
95
|
+
}
|
96
|
+
}else if($(this).hasClass('fa-list')){
|
97
|
+
begin_str = '<ul>\n <li>';
|
98
|
+
end_str = '</li>\n</ul>';
|
99
|
+
if(window.mode_markdown){
|
100
|
+
begin_str = '- ';
|
101
|
+
end_str = '';
|
102
|
+
}
|
103
|
+
}else if($(this).hasClass('fa-list-ol')){
|
104
|
+
begin_str = '<ol>\n <li>';
|
105
|
+
end_str = '</li>\n</ol>';
|
106
|
+
if(window.mode_markdown){
|
107
|
+
begin_str = '1. ';
|
108
|
+
end_str = '';
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
let obj_cursor = window.myCodeMirror.getCursor();
|
113
|
+
window.myCodeMirror.replaceSelection(begin_str + window.myCodeMirror.getSelection() + end_str);
|
114
|
+
if(!window.myCodeMirror.somethingSelected()){
|
115
|
+
let moreline = (begin_str.split('\n').length > 1 ? begin_str.split('\n').length / 2 : 0);
|
116
|
+
let morech = (moreline > 0 ? begin_str.split('\n')[begin_str.split('\n').length - 1].length : begin_str.length);
|
117
|
+
window.myCodeMirror.setCursor({ line: obj_cursor.line + moreline, ch: obj_cursor.ch + morech });
|
118
|
+
}
|
119
|
+
window.myCodeMirror.focus();
|
120
|
+
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<h2><%= t.edit.capitalize %></h2>
|
2
|
+
|
3
|
+
<form action="/files/update?file=<%= @file %>" method="post">
|
4
|
+
<% if @has_header %>
|
5
|
+
<div class="mb-3">
|
6
|
+
<label for="i-header" class="form-label"><%= t.header.capitalize %></label>
|
7
|
+
<textarea class="form-control text-editor" id="i-header" rows="3" name="header" style="font-family: <%= (['.html', '.xml', '.yml', '.js', '.md'].include?(File.extname(@file)) ? 'monospace' : 'inherit') %>"><%= @header %></textarea>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
<div class="mb-3">
|
11
|
+
<label for="i-content" class="form-label"><%= t.content.capitalize %>
|
12
|
+
<% if ['.html','.md'].include?(File.extname(@file)) %>
|
13
|
+
<a href="https://jekyllrb.com/docs/liquid/" class="text-secondary" target="_blank"><i class="fas fa-question-circle"></i></a>
|
14
|
+
<% end %>
|
15
|
+
</label>
|
16
|
+
|
17
|
+
<% if @has_editor %>
|
18
|
+
<% path = File.join(Pathname.new(File.dirname(__FILE__)).parent, 'editor_html.erb') %>
|
19
|
+
<%= ERB.new(File.read(path)).result(binding) %>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<textarea class="form-control text-editor" id="i-content" rows="3" name="content" style="font-family: <%= (['.html', '.xml', '.yml', '.js', '.md'].include?(File.extname(@file)) ? 'monospace' : 'inherit') %>"><%= @content %></textarea>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8">
|
25
|
+
<% path = File.join(Pathname.new(File.dirname(__FILE__)).parent, 'editor_js.erb') %>
|
26
|
+
<%= ERB.new(File.read(path)).result(binding) %>
|
27
|
+
</script>
|
28
|
+
</div>
|
29
|
+
<button type="submit" class="btn btn-primary"><%= t.submit.capitalize %></button>
|
30
|
+
</form>
|