diff options
author | 2020-10-10 13:32:33 +0200 | |
---|---|---|
committer | 2020-10-10 13:32:33 +0200 | |
commit | a17d52aeb7b2c87cfc09f7d271f51c53818b906c (patch) | |
tree | f8b2d4d172ea3b1511df61c2d21f877755354282 | |
parent | 9a93d62940bceadd1fe38205d38e211a4cf25d0f (diff) | |
parent | 7537c6f70fcb3fa7da888a5893d5bdecc76605e3 (diff) | |
download | fronde-0.1.4.tar.gz fronde-0.1.4.tar.xz fronde-0.1.4.zip |
chore: Merge branch 'v0.1.4-dev' into masterv0.1.4
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .rubocop.yml | 2 | ||||
-rw-r--r-- | .ruby-version | 1 | ||||
-rw-r--r-- | CONFIG.org | 25 | ||||
-rw-r--r-- | Gemfile | 22 | ||||
-rw-r--r-- | Gemfile.lock | 85 | ||||
-rw-r--r-- | README.org | 12 | ||||
-rwxr-xr-x | bin/pablo | 25 | ||||
-rw-r--r-- | lib/neruda/config.rb | 6 | ||||
-rw-r--r-- | lib/neruda/index/atom_generator.rb | 2 | ||||
-rw-r--r-- | lib/neruda/utils.rb | 52 | ||||
-rw-r--r-- | lib/neruda/version.rb | 2 | ||||
-rw-r--r-- | locales/en.yml | 18 | ||||
-rw-r--r-- | locales/fr.yml | 18 | ||||
-rw-r--r-- | neruda.gemspec | 20 | ||||
-rw-r--r-- | spec/index_spec.rb | 8 | ||||
-rw-r--r-- | spec/requirements.rb | 3 |
17 files changed, 185 insertions, 118 deletions
@@ -1,6 +1,6 @@ .byebug_history .ignore -.ruby-gemset +.ruby-* neruda-*.gem doc coverage diff --git a/.rubocop.yml b/.rubocop.yml index 1b1e563..016e832 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ --- AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 Layout: Severity: warning diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index a7b1491..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.6.5
\ No newline at end of file @@ -18,7 +18,10 @@ files contains an ~#+author:~ metadata field before publishing them. This value is used in the generation of the blog index page and the main atom feed. -* <<sec:blog_path>> ~blog_path~ +* ~blog_path~ +:PROPERTIES: +:CUSTOM_ID: sec-blog_path +:END: The ~blog_path~ options store the folder name *inside* the ~src~ folder, which will contains org document to be specifically indexed to produce a @@ -31,15 +34,18 @@ page at the root of this folder. The default value is ~blog~. -* <<sec:blog_pattern>> ~blog_pattern~ +* ~blog_pattern~ +:PROPERTIES: +:CUSTOM_ID: sec-blog_pattern +:END: The ~blog_pattern~ option stores a [[https://en.wikipedia.org/wiki/Glob_(programming)][glob pattern]] to help Neruda to find -the documents you want to index under the [[sec:blog_path][~blog_path~]] folder. It may be +the documents you want to index under the [[#sec-blog_path][~blog_path~]] folder. It may be handy to only selecte precisely some files. The default value is ~**/*.org~, which means absolutely all org documents (under the ~blog_path~). -See also the [[sec:exclude_pattern][~exclude_pattern~ section]]. +See also the [[#sec-exclude_pattern][~exclude_pattern~ section]]. * ~domain~ @@ -59,19 +65,22 @@ value. Thus, ~https://example.com/example~ or ~https://example.com/example/~ or ~https://example.com/complex/example/~ are not. -* <<sec:exclude_pattern>> ~exclude_pattern~ +* ~exclude_pattern~ +:PROPERTIES: +:CUSTOM_ID: sec-exclude_pattern +:END: The ~exclude_pattern~ option stores a [[https://en.wikipedia.org/wiki/Regular_expression][regular expression]] to help Neruda -to find precisely which files you want to index under the [[sec:blog_path][~blog_path~]] +to find precisely which files you want to index under the [[#sec-blog_path][~blog_path~]] folder. It may be handy to remove some unrelated data files, for example with a value like ~comments\.org$~. This filter is executed *after* -files have been selected by the [[sec:blog_pattern][~blog_pattern~]] and *matching* files are +files have been selected by the [[#sec-blog_pattern][~blog_pattern~]] and *matching* files are excluded. There is no default value (thus nothing match and thus all org files matched by the ~blog_pattern~ option are indexed). -See also the [[sec:blog_pattern][~blog_pattern~ section]]. +See also the [[#sec-blog_pattern][~blog_pattern~ section]]. * ~lang~ @@ -2,19 +2,19 @@ source 'https://rubygems.org' -ruby '>= 2.5' +ruby '>= 2.6' gem 'nokogiri', '~> 1.10' -gem 'r18n-core', '~> 3.2' +gem 'r18n-core', '~> 4.0' gem 'rainbow', '~> 3.0' -gem 'rake', '~> 12.3' +gem 'rake', '~> 13.0' group :development do - gem 'byebug' - gem 'org-ruby' - gem 'pry' - gem 'pry-doc' - gem 'rspec' - gem 'rubocop' - gem 'simplecov' - gem 'yard' + gem 'byebug', '~> 11.1' + gem 'org-ruby', '~> 0.9' + gem 'pry', '~> 0.13' + gem 'pry-doc', '~> 1.1' + gem 'rspec', '~> 3.9' + gem 'rubocop', '~> 0.90' + gem 'simplecov', '~> 0.19' + gem 'yard', '~> 0.9' end diff --git a/Gemfile.lock b/Gemfile.lock index 64fd8f0..863c4a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,77 +1,80 @@ GEM remote: https://rubygems.org/ specs: - ast (2.4.0) - byebug (11.1.0) - coderay (1.1.2) - diff-lcs (1.3) + ast (2.4.1) + byebug (11.1.3) + coderay (1.1.3) + diff-lcs (1.4.4) docile (1.3.2) - jaro_winkler (1.5.4) - json (2.3.0) - method_source (0.9.2) + method_source (1.0.0) mini_portile2 (2.4.0) - nokogiri (1.10.7) + nokogiri (1.10.10) mini_portile2 (~> 2.4.0) org-ruby (0.9.12) rubypants (~> 0.2) - parallel (1.19.1) - parser (2.7.0.2) - ast (~> 2.4.0) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-doc (1.0.0) + parallel (1.19.2) + parser (2.7.1.4) + ast (~> 2.4.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-doc (1.1.0) pry (~> 0.11) yard (~> 0.9.11) - r18n-core (3.2.0) + r18n-core (4.0.0) rainbow (3.0.0) - rake (12.3.3) + rake (13.0.1) + regexp_parser (1.7.1) + rexml (3.2.4) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) - rspec-support (3.9.2) - rubocop (0.79.0) - jaro_winkler (~> 1.5.1) + rspec-support (3.9.3) + rubocop (0.90.0) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 2.7.1.1) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.7) + rexml + rubocop-ast (>= 0.3.0, < 1.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (0.3.0) + parser (>= 2.7.1.4) ruby-progressbar (1.10.1) rubypants (0.7.1) - simplecov (0.17.1) + simplecov (0.19.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - unicode-display_width (1.6.1) - yard (0.9.24) + simplecov-html (~> 0.11) + simplecov-html (0.12.2) + unicode-display_width (1.7.0) + yard (0.9.25) PLATFORMS ruby DEPENDENCIES - byebug + byebug (~> 11.1) nokogiri (~> 1.10) - org-ruby - pry - pry-doc - r18n-core (~> 3.2) + org-ruby (~> 0.9) + pry (~> 0.13) + pry-doc (~> 1.1) + r18n-core (~> 4.0) rainbow (~> 3.0) - rake (~> 12.3) - rspec - rubocop - simplecov - yard + rake (~> 13.0) + rspec (~> 3.9) + rubocop (~> 0.90) + simplecov (~> 0.19) + yard (~> 0.9) RUBY VERSION ruby 2.6.3p62 @@ -15,13 +15,13 @@ default org mode HTML exporting/publishing routine. * Features -- Inherit all [[https://orgmode.org][org mode features]] (tables, syntax highlighting, +- Inherits all [[https://orgmode.org][org mode features]] (tables, syntax highlighting, code blocks evaluation, multiple languages support…) -- Do not require any emacs lisp knowledge -- Do not require any server-side code, nor databases -- Allow fine customization of generated html files -- Switch easily between various themes -- Native tags and [[https://en.wikipedia.org/wiki/Atom_(Web_standard)][ATOM feeds]] support +- Does not require any emacs lisp knowledge +- Does not require any server-side code, nor databases +- Allows fine customization of generated html files +- Allows easy switch between various themes +- Supports tags and [[https://en.wikipedia.org/wiki/Atom_(Web_standard)][ATOM feeds]] * How to install it @@ -57,8 +57,7 @@ module PabloCommands o = Neruda::OrgFile.new(filename, @options) o.write unless File.exist? filename editor = ENV['EDITOR'] || ENV['VISUAL'] || 'emacs' - cmd = [editor, filename] - cmd.insert(1, '+6') if editor.match?(/^emacs/) + cmd = [editor, '+6', filename] system(*cmd) end alias_method :pablo_edit, :pablo_open @@ -72,10 +71,11 @@ module PabloCommands cmd = Neruda::Utils.resolve_possible_alias(command) cmd_opt = Neruda::Utils::PABLO_COMMANDS[cmd] label = cmd_opt[:label] || command - warn "Usage: pablo #{label} [options]\n\n" - warn cmd_opt[:desc] + "\n\n" if cmd_opt.has_key?(:desc) - warn "Options\n#{Neruda::Utils.summarize_command(cmd)}\n" - warn "Commands\n#{Neruda::Utils.list_commands}\n" if cmd == 'basic' + warn R18n.t.pablo.usage(label) + "\n\n" + if R18n.t.pablo.commands[cmd].translated? + warn R18n.t.pablo.commands[cmd] + "\n\n" + end + warn help_command_body(cmd).join("\n") exit 1 if error exit end @@ -89,6 +89,19 @@ module PabloCommands return "#{filename}.org" unless @options[:directory] "#{filename}/index.org" end + + def help_command_body(command) + body = [ + R18n.t.pablo.options.cmd_title, + Neruda::Utils.summarize_command(command) + ] + return body unless command == 'basic' + body + [ + '', + R18n.t.pablo.commands.cmd_title, + Neruda::Utils.list_commands + ] + end end # Main pablo class diff --git a/lib/neruda/config.rb b/lib/neruda/config.rb index d76aa9c..a43a067 100644 --- a/lib/neruda/config.rb +++ b/lib/neruda/config.rb @@ -80,8 +80,12 @@ module Neruda @config.freeze end + def extract_lang_from_env(default) + (ENV['LANG'] || default).split('_', 2).first + end + def add_default_settings - @config['lang'] ||= 'en' + @config['lang'] ||= extract_lang_from_env 'en' @config['author'] ||= (ENV['USER'] || '') @config['domain'] ||= '' @config['public_folder'] ||= 'public_html' diff --git a/lib/neruda/index/atom_generator.rb b/lib/neruda/index/atom_generator.rb index 38c50fc..5e7787d 100644 --- a/lib/neruda/index/atom_generator.rb +++ b/lib/neruda/index/atom_generator.rb @@ -55,7 +55,7 @@ module Neruda <updated>#{upddate}</updated> <author><name>#{Neruda::Config.settings['author'] || ''}</name></author> <id>urn:md5:#{Digest::MD5.hexdigest(domain)}</id> - <generator uri="https://fossil.deparis.io/neruda">Neruda</generator> + <generator uri="https://git.umaneti.net/neruda/about/">Neruda</generator> ENDATOM end diff --git a/lib/neruda/utils.rb b/lib/neruda/utils.rb index ffa74f3..cfa15c3 100644 --- a/lib/neruda/utils.rb +++ b/lib/neruda/utils.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'rainbow' +require 'r18n-core' require 'neruda/config' module Neruda @@ -25,33 +26,24 @@ module Neruda '-a' => { long: 'author' }, '-l' => { long: 'lang', keyword: 'LOCALE' }, '-t' => { long: 'title' }, - '-p' => { long: 'path', desc: 'Path to the new file' }, - '-d' => { long: 'directory', boolean: true, - desc: 'Wrap the new org file in a named folder' }, + '-p' => { long: 'path' }, + '-d' => { long: 'directory', boolean: true }, '-v' => { long: 'verbose', boolean: true, meth: :on_tail }, - '-h' => { long: 'help', boolean: true, meth: :on_tail, - desc: 'Display help for a command and exit' }, - '-V' => { long: 'version', boolean: true, meth: :on_tail, - desc: 'Display Neruda version and exit' } + '-h' => { long: 'help', boolean: true, meth: :on_tail }, + '-V' => { long: 'version', boolean: true, meth: :on_tail } }.freeze # @return [Hash] the possible ~pablo~ subcommands and their # configuration PABLO_COMMANDS = { - 'init' => { opts: ['-a', '-l', '-t', '-v', '-h'], - desc: 'Initialize your Neruda instance ' \ - '(you just need to do it once).' }, + 'init' => { opts: ['-a', '-l', '-t', '-v', '-h'] }, 'config' => { alias: 'init' }, - 'preview' => { opts: ['-h'], - desc: 'Start a test webserver to preview ' \ - 'your website on http://127.0.0.1:5000' }, - 'open' => { opts: ['-a', '-l', '-t', '-d', '-p', '-v', '-h'], - desc: 'Open or create an org file for edition.' }, + 'preview' => { opts: ['-h'] }, + 'open' => { opts: ['-a', '-l', '-t', '-d', '-p', '-v', '-h'] }, 'edit' => { alias: 'open' }, - 'publish' => { opts: ['-h'], - desc: 'Push local changes to your public ' \ - 'server online.' }, - 'help' => { opts: ['-h'], desc: 'Alias for the -h switch.' }, + 'build' => { opts: ['-h'] }, + 'publish' => { opts: ['-h'] }, + 'help' => { opts: ['-h'] }, 'basic' => { opts: ['-h', '-V'], label: '<command>' } }.freeze @@ -115,22 +107,30 @@ module Neruda Neruda::Utils::PABLO_COMMANDS[command][:opts].map do |k| short, long = Neruda::Utils.decorate_option(k) opt = Neruda::Utils::PABLO_OPTIONS[k] - line = ' ' + [short, long].join(', ') - line = line.ljust(34) + " #{opt[:desc]}" if opt.has_key?(:desc) - line + "\n" - end.join + line = [(' ' + [short, long].join(', ')).ljust(30)] + if R18n.t.pablo.options[opt[:long]].translated? + line << R18n.t.pablo.options[opt[:long]] + end + line.join(' ') + end.join("\n") end # Returns a formatted list of available commands for ~pablo~. # # @return [String] def list_commands - lines = '' + lines = [] Neruda::Utils::PABLO_COMMANDS.each do |cmd, opt| next if cmd == 'basic' - lines += " #{cmd.ljust(10)} #{opt[:desc]}\n" + line = [' ', cmd.ljust(10)] + if opt.has_key? :alias + line << R18n.t.pablo.commands.alias(opt[:alias]) + elsif R18n.t.pablo.commands[cmd].translated? + line << R18n.t.pablo.commands[cmd] + end + lines << line.join(' ') end - lines + lines.join("\n") end # Returns the real command name for a given command, which may be diff --git a/lib/neruda/version.rb b/lib/neruda/version.rb index 3cc81c2..18e2c62 100644 --- a/lib/neruda/version.rb +++ b/lib/neruda/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Neruda - VERSION = '0.1.3' + VERSION = '0.1.4' end diff --git a/locales/en.yml b/locales/en.yml index 6bd5b0e..6279550 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -2,6 +2,22 @@ pablo: error: no_command: 'ERROR: no command or unknown command given.' + usage: 'Usage: pablo %1 [options]' + commands: + cmd_title: Commands + alias: Alias for %1. + init: Initialize your Neruda instance (you just need to do it once). + preview: 'Start a test web server to preview your website on http://127.0.0.1:5000' + open: Open or create an org file. + build: Compile your org files to HTML. + publish: Push local changes to your public web server. + help: Alias for the -h switch. + options: + cmd_title: Options + path: Path to the new file. + directory: Wrap the new org file in this named folder. + help: Display help for a command and exit. + version: Display Neruda version and exit. neruda: index: unsorted: Unsorted @@ -14,5 +30,5 @@ neruda: org: postamble: written_by: Written by %a - with_emacs: with %c, and published with <a href="https://deparis.io/neruda">Neruda</a> + with_emacs: 'with %c, and published with <a href="https://git.umaneti.net/neruda/about/">Neruda</a>' last_modification: Last modification on %C diff --git a/locales/fr.yml b/locales/fr.yml index 573a848..55b7858 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -2,6 +2,22 @@ pablo: error: no_command: 'ERREUR: Aucune commande ou commande inconnue donnée.' + usage: 'Usage : pablo %1 [options]' + commands: + cmd_title: Commandes + alias: Alias pour %1. + init: Initialise votre instance de Neruda (vous ne devriez faire cela qu'une fois). + preview: "Démarre un serveur web de test pour prévisualiser votre site à l'adresse http://127.0.0.1:5000" + open: Ouvre ou crée un fichier org. + build: Compile vos fichiers org en HTML. + publish: Pousse vos changements locaux vers votre serveur web public. + help: Alias pour l'argument -h. + options: + cmd_title: Options + path: Chemin vers le nouveau fichier. + directory: Place le nouveau fichier org dans un dossier à ce nom. + help: Affiche l'aide pour une commande et quitte. + version: Affiche la version de Neruda et quitte. neruda: index: unsorted: Non triés @@ -14,5 +30,5 @@ neruda: org: postamble: written_by: Écrit par %a - with_emacs: avec %c et publié avec <a href="https://deparis.io/neruda">Neruda</a> + with_emacs: 'avec %c et publié avec <a href="https://git.umaneti.net/neruda/about/">Neruda</a>' last_modification: dernière modification le %C diff --git a/neruda.gemspec b/neruda.gemspec index dc041be..0d481dc 100644 --- a/neruda.gemspec +++ b/neruda.gemspec @@ -42,24 +42,24 @@ Gem::Specification.new do |s| # Others 'LICENSE'] s.executables = ['pablo'] - s.homepage = 'https://git.deparis.io/neruda/' + s.homepage = 'https://git.umaneti.net/neruda/about/' s.license = 'WTFPL' s.rdoc_options << '-m' << 'org' s.extra_rdoc_files = ['LICENSE'] - s.required_ruby_version = '>= 2.5' + s.required_ruby_version = '>= 2.6' s.add_runtime_dependency 'nokogiri', '~> 1.10' - s.add_runtime_dependency 'r18n-core', '~> 3.2' + s.add_runtime_dependency 'r18n-core', '~> 4.0' s.add_runtime_dependency 'rainbow', '~> 3.0' - s.add_runtime_dependency 'rake', '~> 12.3' + s.add_runtime_dependency 'rake', '~> 13.0' - s.add_development_dependency 'byebug', '~> 11.0' + s.add_development_dependency 'byebug', '~> 11.1' s.add_development_dependency 'org-ruby', '~> 0.9' - s.add_development_dependency 'pry', '~> 0.12' - s.add_development_dependency 'pry-doc', '~> 1.0' - s.add_development_dependency 'rspec', '~> 3.8' - s.add_development_dependency 'rubocop', '~> 0.70' - s.add_development_dependency 'simplecov', '~> 0.16' + s.add_development_dependency 'pry', '~> 0.13' + s.add_development_dependency 'pry-doc', '~> 1.1' + s.add_development_dependency 'rspec', '~> 3.9' + s.add_development_dependency 'rubocop', '~> 0.90' + s.add_development_dependency 'simplecov', '~> 0.19' s.add_development_dependency 'yard', '~> 0.9' end diff --git a/spec/index_spec.rb b/spec/index_spec.rb index d30257e..c3a9dcc 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -36,7 +36,7 @@ SAMPLE_ATOM = <<~ATOM <updated>%s</updated> <author><name>Test</name></author> <id>urn:md5:75d53866bcb20465b3287cf237234464</id> - <generator uri="https://fossil.deparis.io/neruda">Neruda</generator> + <generator uri="https://git.umaneti.net/neruda/about/">Neruda</generator> <entry> <title>My third article</title> @@ -73,6 +73,10 @@ SAMPLE_ATOM = <<~ATOM ATOM describe 'With blog settings' do + before(:all) do + ENV['LANG'] = 'en' + end + describe 'with working org files' do before(:each) do Neruda::Config.load_test('title' => 'Blog', @@ -194,7 +198,7 @@ describe 'Without blog settings' do <updated>%s</updated> <author><name>Test</name></author> <id>urn:md5:75d53866bcb20465b3287cf237234464</id> - <generator uri="https://fossil.deparis.io/neruda">Neruda</generator> + <generator uri="https://git.umaneti.net/neruda/about/">Neruda</generator> </feed> EMPTY_ATOM expect(@index.to_atom).to eq(empty_atom.strip % @index.date.rfc3339) diff --git a/spec/requirements.rb b/spec/requirements.rb index 7e1ad50..faab8d0 100644 --- a/spec/requirements.rb +++ b/spec/requirements.rb @@ -10,6 +10,9 @@ R18n::Filters.on(:named_variables) $LOAD_PATH.unshift('./lib') SimpleCov.start do + # Activate new covering precision + enable_coverage :branch + # Remove dev only tools from coverage check add_filter ['lib/tasks/sync.rake', 'lib/tasks/doc.rake'] # Sort coverage results into usefull groups |