hyde_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 86a33a78224ec1d89dfeeff5a08fe950a70239c86619da735ec6334077e09a70
4
+ data.tar.gz: 6e2e187ee97382f101be3cc47de763dd0d2b9d8afc5856d546d9c02b60a088c1
5
+ SHA512:
6
+ metadata.gz: 1591e20b85a070ea7d992233c0e63b1f92283392b1f713f1754be3fdc5669dc7cd2476404c4a266ac1ab2f3d9a5dfb805e23a1c5f63c5ab8b8374d17818f9318
7
+ data.tar.gz: 0f99763e3a04d7829c4768da18cfc0fab9b6d6a0ee80a2fb47faf0f08aecd214be58dd12c1897e44572adeed602b04d9c467d6fcbbd17509a2a51fd12059673b
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ </component>
15
+ <component name="RModuleSettingsStorage">
16
+ <LOAD_PATH number="0" />
17
+ <I18N_FOLDERS number="1" string0="$MODULE_DIR$/i18n" />
18
+ </component>
19
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.7.0" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/hyde_admin.iml" filepath="$PROJECT_DIR$/.idea/hyde_admin.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,131 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Hyde for Jekyll</title>
6
+
7
+ <meta name="description" content="Hyde for Jekyll">
8
+ <meta name="author" content="Sylvain Claudel (https://blog.rivsc.ovh)">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+
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
+ <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
+ <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
+
15
+ </head>
16
+ <body>
17
+
18
+ <div class="container-fluid">
19
+ <div class="row">
20
+ <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
21
+ <div class="position-sticky pt-3">
22
+ <ul class="nav flex-column">
23
+ <li class="nav-item">
24
+ <a class="nav-link active" aria-current="page" href="/">
25
+ <span data-feather="home"></span>
26
+ Site
27
+ </a>
28
+ </li>
29
+ <li class="nav-item">
30
+ <a class="nav-link active" aria-current="page" href="/dashboard">
31
+ <span data-feather="home"></span>
32
+ <%= t.dashboard %>
33
+ </a>
34
+ </li>
35
+ <li class="nav-item">
36
+ <a class="nav-link active" aria-current="page" href="/deploy">
37
+ <span data-feather="home"></span>
38
+ <%= t.deploy %>
39
+ </a>
40
+ </li>
41
+ <li class="nav-item">
42
+ <a class="nav-link active" aria-current="page" href="/rebuild">
43
+ <span data-feather="home"></span>
44
+ <%= t.rebuild %>
45
+ </a>
46
+ </li>
47
+ <li class="nav-item">
48
+ <a class="nav-link" href="/pages/index">
49
+ <span data-feather="file"></span>
50
+ <%= t.pages %>
51
+ </a>
52
+ </li>
53
+ <li class="nav-item">
54
+ <a class="nav-link" href="/drafts/index">
55
+ <span data-feather="shopping-cart"></span>
56
+ <%= t.drafts %>
57
+ </a>
58
+ </li>
59
+ <li class="nav-item">
60
+ <a class="nav-link" href="/posts/index">
61
+ <span data-feather="users"></span>
62
+ <%= t.posts %>
63
+ </a>
64
+ </li>
65
+ <li class="nav-item">
66
+ <a class="nav-link" href="/configuration">
67
+ <span data-feather="layers"></span>
68
+ <%= t.configuration %>
69
+ </a>
70
+ </li>
71
+ </ul>
72
+
73
+ <!--
74
+ <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
75
+ <span>Saved reports</span>
76
+ <a class="link-secondary" href="#" aria-label="Add a new report">
77
+ <span data-feather="plus-circle"></span>
78
+ </a>
79
+ </h6>
80
+ <ul class="nav flex-column mb-2">
81
+ <li class="nav-item">
82
+ <a class="nav-link" href="#">
83
+ <span data-feather="file-text"></span>
84
+ Current month
85
+ </a>
86
+ </li>
87
+ <li class="nav-item">
88
+ <a class="nav-link" href="#">
89
+ <span data-feather="file-text"></span>
90
+ Last quarter
91
+ </a>
92
+ </li>
93
+ <li class="nav-item">
94
+ <a class="nav-link" href="#">
95
+ <span data-feather="file-text"></span>
96
+ Social engagement
97
+ </a>
98
+ </li>
99
+ <li class="nav-item">
100
+ <a class="nav-link" href="#">
101
+ <span data-feather="file-text"></span>
102
+ Year-end sale
103
+ </a>
104
+ </li>
105
+ </ul>
106
+ -->
107
+ </div>
108
+ </nav>
109
+
110
+ <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
111
+ <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
112
+ <h1 class="h2">Dashboard</h1>
113
+ <div class="btn-toolbar mb-2 mb-md-0">
114
+ <div class="btn-group me-2">
115
+ <button type="button" class="btn btn-sm btn-outline-secondary">Share</button>
116
+ <button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
117
+ </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
+ </div>
123
+ </div>
124
+ <%= yield %>
125
+
126
+ </main>
127
+ </div>
128
+ </div>
129
+
130
+ </body>
131
+ </html>
@@ -0,0 +1 @@
1
+ dashboard
@@ -0,0 +1,57 @@
1
+ <h2><%= t.send(@type_file) %></h2>
2
+
3
+ <form action="/<%= @type_file %>?file=<%= @file %>" method="post">
4
+ <div class="mb-3">
5
+ <label for="i-path" class="form-label"><%= t.path %></label>
6
+ <input type="text" class="form-control" value="<%= @file %>" name="new_file" id="i-path">
7
+ <!--<div id="emailHelp" class="form-text">Name of file</div>-->
8
+ </div>
9
+ <div class="mb-3">
10
+ <label for="i-title" class="form-label"><%= t.title %></label>
11
+ <input type="text" value="<%= @headers['title'] %>" class="form-control" name="title" id="i-title">
12
+ </div>
13
+ <div class="mb-3">
14
+ <label for="i-date" class="form-label"><%= t.date %></label>
15
+ <input type="text" value="<%= @headers['date'] %>" class="form-control" name="date" id="i-date">
16
+ </div>
17
+ <div class="mb-3">
18
+ <label for="i-tags" class="form-label"><%= t.tags %></label>
19
+ <input type="text" value="<%= @headers['tags'] %>" class="form-control" name="tags" id="i-tags">
20
+ </div>
21
+ <div class="mb-3 form-check">
22
+ <input type="checkbox" class="form-check-input" name="publish" id="i-publish">
23
+ <label class="form-check-label" for="i-publish"><%= t.publish %></label>
24
+ </div>
25
+
26
+ <div class="mb-3">
27
+ <label for="i-layout" class="form-label"><%= t.layout %></label>
28
+ <select class="form-select" aria-label="Choice layout" name="layout">
29
+ <% Dir.glob(File.join(@hyde_parameters['path_to_jekyll_src'], '_layouts', '*')).each do |f| %>
30
+ <% layout = File.basename(f, File.extname(f)) %>
31
+ <option <%= (@headers['layout'] == f ? 'selected' : '') %> value="<%= layout %>"><%= layout %></option>
32
+ <% end %>
33
+ </select>
34
+ </div>
35
+
36
+ <div class="mb-3">
37
+ <label for="i-content" class="form-label"><%= t.content %></label>
38
+ <textarea class="form-control" id="i-content" rows="3" name="content"><%#= %></textarea>
39
+ </div>
40
+
41
+ <!--
42
+ <div class="form-check">
43
+ <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
44
+ <label class="form-check-label" for="flexCheckDefault">
45
+ Default checkbox
46
+ </label>
47
+ </div>
48
+ <div class="form-check">
49
+ <input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" checked>
50
+ <label class="form-check-label" for="flexCheckChecked">
51
+ Checked checkbox
52
+ </label>
53
+ </div>
54
+ -->
55
+ <button type="submit" class="btn btn-primary">Submit</button>
56
+ </form>
57
+
@@ -0,0 +1,32 @@
1
+ <h2><%= t.send(@type_file) %></h2>
2
+ <div class="table-responsive">
3
+ <table class="table table-striped table-sm">
4
+ <tr>
5
+ <th>
6
+ <%= t.file %>
7
+ </th>
8
+ <th>
9
+ <%= t.edit %>
10
+ </th>
11
+ <th>
12
+ <%= t.delete %>
13
+ </th>
14
+ </tr>
15
+ <% @files.each do |f| %>
16
+ <tr>
17
+ <td>
18
+ <%= f %>
19
+ </td>
20
+ <td>
21
+ <a href="/<%= @type_file %>?file=<%= f %>" class="btn btn-default"><i class="fa fa-edit" title="<%= t.edit %>"></i></a>
22
+ </td>
23
+ <td>
24
+ <form method="post" action="/<%= @type_file %>/delete?file=<%= f %>" class="inline">
25
+ <button type="submit" class="btn btn-default"><i class="fa fa-trash" title="<%= t.delete %>"></i></button>
26
+ </form>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </table>
31
+ </div>
32
+
data/bin/hyde_admin.ru ADDED
@@ -0,0 +1,143 @@
1
+ # cat config.ru
2
+ # lancer avec rackup
3
+ require "roda"
4
+ require 'yaml'
5
+
6
+ class App < Roda
7
+ YML_FILE_NAME = "hyde_admin.yml"
8
+
9
+ plugin :render,
10
+ #escape: true, # Automatically escape output in erb templates using Erubi's escaping support
11
+ views: 'admin_views', # Default views directory
12
+ layout_opts: {template: 'admin_layout', engine: 'html.erb'}, # Default layout options
13
+ template_opts: {default_encoding: 'UTF-8'} # Default template options
14
+
15
+ plugin :i18n, translations: './i18n' # gem 'roda-i18n'
16
+
17
+ opts[:root] = Dir.pwd
18
+
19
+ plugin :public, root: "#{YAML.load(File.read(YML_FILE_NAME))['path_to_jekyll_src']}/_site" # permet de simuler le serveur jekyll
20
+
21
+ # TODO load option (default_layout, deploy_dest_address, deploy_dest_path, path_to_jekyll_src, rsync_fullpath)
22
+ # expliquer dans la doc le hyde.yml (voir une commande pour le prégénérer)
23
+
24
+ def initialize(param)
25
+ puts "============> #{Dir.pwd}"
26
+ yml_in_current_dir = File.join(Dir.pwd, YML_FILE_NAME)
27
+ yml_in_gem = File.expand_path(File.join(File.dirname(__FILE__), YML_FILE_NAME))
28
+
29
+ puts yml_in_current_dir
30
+ puts yml_in_gem
31
+
32
+ # Generate default YML for hyde_admin
33
+ if !File.exist?(yml_in_current_dir)
34
+ File.cp(yml_in_gem, yml_in_current_dir)
35
+ end
36
+ @hyde_parameters ||= YAML.load(File.read(yml_in_current_dir))
37
+ super(param)
38
+ end
39
+
40
+ route do |r|
41
+ # GET serve static blog (chercher l'url index.html dans le navigateur
42
+ r.public
43
+
44
+ r.root do
45
+ r.redirect "/dashboard"
46
+ end
47
+
48
+ r.on "overview" do
49
+ r.redirect @hyde_parameters['site_index']
50
+ end
51
+
52
+ # need to install jekyll (version bundlé avec le site
53
+ r.on "rebuild" do
54
+ puts @hyde_parameters['path_to_jekyll_src']
55
+ `cd #{@hyde_parameters['path_to_jekyll_src']} && jekyll b && sleep 10`
56
+ r.redirect "/dashboard"
57
+ end
58
+
59
+ r.on "deploy" do
60
+ `#{@hyde_parameters['rsync_fullpath']} #{@hyde_parameters['path_to_jekyll_src']}/_site/ #{@hyde_parameters['deploy_dest_user']}@#{@hyde_parameters['deploy_dest_address']}:#{@hyde_parameters['deploy_dest_path']}`
61
+ r.redirect "/dashboard"
62
+ end
63
+
64
+ r.on "configuration" do
65
+ File.open("hyde.yml","w+") do |f|
66
+ f.write(@hyde_parameters.to_yaml)
67
+ end
68
+ r.redirect "/dashboard"
69
+ end
70
+
71
+ r.on "dashboard" do
72
+ view("dashboard")
73
+ end
74
+
75
+ # Posts/pages/drafts
76
+ r.on /posts|pages|drafts/ do
77
+ # Set variable for all routes in /hello branch
78
+ @type_file = r.matched_path.split('/').compact.select{ |elt| elt != '' }.first
79
+
80
+ # GET /posts/index request
81
+ # list all posts...
82
+ r.get "index" do
83
+ @files = Dir[File.join(@hyde_parameters['path_to_jekyll_src'], "_#{@type_file}", '*')].sort
84
+ view("listing")
85
+ end
86
+
87
+ r.is do
88
+ # GET /posts?file=truc request
89
+ # edit the truc post
90
+ r.get do
91
+ @file = r.params['file']
92
+
93
+ content_file = File.read(@file)
94
+ @headers = content_file.scan(/---(.*?)---/m).flatten.first.split("\n")
95
+ @headers = @headers.select{ |header| !header.empty? }.map{ |header| header.scan(/([a-zA-Z]*): (.*)/).flatten }
96
+ pp @headers
97
+ @headers = Hash[@headers]
98
+
99
+ view("edit")
100
+ end
101
+
102
+ # POST /posts?file=truc request
103
+ # save the truc post
104
+ r.post do
105
+ @file = r.params['file']
106
+ @content = r.params['content']
107
+ @filename = r.params['filename']
108
+ @tags = r.params['tags']
109
+ @content = r.params['content']
110
+ @date = r.params['date']
111
+ @meta = r.params['meta']
112
+ @format = r.params['format']
113
+ @publish = r.params['publish']
114
+ @layout = r.params['layout']
115
+
116
+ @headers = ['---']
117
+ @headers << ['tags', @tags.join(',')].join(': ')
118
+ @headers << ['layout', @layout].join(': ')
119
+ @headers << ['date', @date.to_s].join(': ')
120
+ #@headers << ['meta', @tags.join(',')].join(': ')
121
+ @headers << ['---']
122
+
123
+ File.open(File.join(@hyde_parameters['path_to_jekyll_src'], "#{@file}.#{@format}"), "w+") do |f|
124
+ f.write(@headers.join("\n"))
125
+ f.write("")
126
+ f.write(content)
127
+ end
128
+ end
129
+
130
+ # POST /posts/delete?file=truc request
131
+ # save the truc post
132
+ r.post "delete" do
133
+ @file = r.params['file']
134
+ File.unlink(File.join(@hyde_parameters['path_to_jekyll_src'],@file))
135
+ end
136
+ end
137
+ end
138
+
139
+ # TODO faire un jekyll serve
140
+ end
141
+ end
142
+
143
+ run App.freeze.app
data/bin/hyde_admin.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ rackup hyde_admin.ru
@@ -0,0 +1,8 @@
1
+ ---
2
+ default_layout:
3
+ deploy_dest_user: pi
4
+ deploy_dest_address: guerin.rivsc.ovh
5
+ deploy_dest_path: "/home/pi/testblog"
6
+ path_to_jekyll_src: "/Users/scl/blog/rivscblog-zolan"
7
+ rsync_fullpath: rsync
8
+ site_index: index.html
data/bin/i18n/en.yml ADDED
@@ -0,0 +1,27 @@
1
+ draft: draft
2
+ drafts: drafts
3
+ page: page
4
+ pages: pages
5
+ post: post
6
+ posts: posts
7
+ save: save
8
+ edit: edit
9
+ delete: delete
10
+ are_you_sure: are you sure
11
+ tag: tag
12
+ tags: tags
13
+ layout: layout
14
+ configuration: configuration
15
+ files: files
16
+ file: file
17
+ title: title
18
+ url: url
19
+ view: view
20
+ format: format
21
+ dashboard: dashboard
22
+ deploy: deploy
23
+ rebuild: rebuild
24
+ date: date
25
+ content: content
26
+ publish: publish
27
+ path: path
data/bin/i18n/fr.yml ADDED
@@ -0,0 +1,27 @@
1
+ draft: brouillon
2
+ drafts: brouillons
3
+ page: page
4
+ pages: pages
5
+ post: article
6
+ posts: articles
7
+ save: sauvegarder
8
+ edit: éditer
9
+ delete: supprimer
10
+ are_you_sure: êtes-vous sûr
11
+ tag: mot-clé
12
+ tags: mots-clés
13
+ layout: présentation
14
+ configuration: configuration
15
+ files: fichiers
16
+ file: fichier
17
+ title: titre
18
+ url: adresse
19
+ view: voir
20
+ format: format
21
+ dashboard: tableau de bord
22
+ deploy: déployer
23
+ rebuild: regénérer
24
+ date: date
25
+ content: contenu
26
+ publish: publier
27
+ path: chemin
@@ -0,0 +1,28 @@
1
+ require_relative "lib/hyde_admin/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'hyde_admin'
5
+ s.version = HydeAdmin::VERSION
6
+ s.summary = "Hyde for Jekyll site"
7
+ s.description = "A Jekyll admin interface"
8
+ s.authors = ["Sylvain Claudel"]
9
+ s.email = 'claudel.sylvain@gmail.com'
10
+
11
+ all_files = `git ls-files`.split("\n").reject{ |filepath| filepath.start_with? 'test/' }
12
+ s.files = all_files
13
+
14
+ s.executables = ['hyde_admin.sh']
15
+ s.bindir = "bin"
16
+ s.require_paths = ["lib"]
17
+
18
+ s.homepage = 'https://rubygems.org/gems/hyde_admin'
19
+
20
+ s.metadata = {
21
+ "source_code_uri" => "https://github.com/rivsc/hyde_admin",
22
+ "bug_tracker_uri" => "https://github.com/rivsc/hyde_admin/issues",
23
+ "changelog_uri" => "https://github.com/rivsc/hyde_admin/releases",
24
+ "homepage_uri" => s.homepage,
25
+ }
26
+
27
+ s.license = 'MIT'
28
+ end
@@ -0,0 +1,3 @@
1
+ module HydeAdmin
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyde_admin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sylvain Claudel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Jekyll admin interface
14
+ email: claudel.sylvain@gmail.com
15
+ executables:
16
+ - hyde_admin.sh
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".idea/.gitignore"
21
+ - ".idea/hyde_admin.iml"
22
+ - ".idea/misc.xml"
23
+ - ".idea/modules.xml"
24
+ - bin/admin_views/admin_layout.html.erb
25
+ - bin/admin_views/dashboard.erb
26
+ - bin/admin_views/edit.erb
27
+ - bin/admin_views/listing.erb
28
+ - bin/hyde_admin.ru
29
+ - bin/hyde_admin.sh
30
+ - bin/hyde_admin.yml
31
+ - bin/i18n/en.yml
32
+ - bin/i18n/fr.yml
33
+ - hyde_admin.gemspec
34
+ - lib/hyde_admin/version.rb
35
+ homepage: https://rubygems.org/gems/hyde_admin
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ source_code_uri: https://github.com/rivsc/hyde_admin
40
+ bug_tracker_uri: https://github.com/rivsc/hyde_admin/issues
41
+ changelog_uri: https://github.com/rivsc/hyde_admin/releases
42
+ homepage_uri: https://rubygems.org/gems/hyde_admin
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.1.4
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Hyde for Jekyll site
62
+ test_files: []