hugo-notion 0.1.0.pre.alpha.7 → 0.1.0.pre.alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -1
  3. data/bin/huno +40 -12
  4. data/lib/hugo_notion/version.rb +1 -1
  5. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7282eb4de7866d96d5410e5c6c75416e740902f58658ea821f771dc464ef4941
4
- data.tar.gz: cf6f91d8d4ed8af6359d59a204be185a65e07ebec200707f5938f0605e8e54a0
3
+ metadata.gz: 11cfde333809056eeb23f2dbbb7132c6f10ad218618a54261413888d3d726e65
4
+ data.tar.gz: 95e38034602fb742ea75ac4240fe47d310de9d1cb4c21cf837763b47205d7cdf
5
5
  SHA512:
6
- metadata.gz: d8fc7b93e0c4276a12dcfeaeb4769a427464d64f5f05a6a5f1a8b4dc83d0c22757a876f97bfa9802d5006430d1907f95e4b3f691c243a6d33ce114cb4405595a
7
- data.tar.gz: '0499a9c8bb1c7e4b442c83d152e04deeca51d9c8d10894019ee377c4d0e6ab647e2ac5408b3395911360906217d84a348f1fd236054de52432a1aeeb1a589503'
6
+ metadata.gz: 8facb0e0f8dd9abd697c23d39a3cabf3dca75adc4569e8299134a32b2c55094d2f17baf592acb9fa69e544127aa9c82fe0bb24afba9133b2dcf8a19fcdcfc25b
7
+ data.tar.gz: e1f850f15f4659593b7712e776387763f6b96f0dc6f446eb03a78f86d991197f2af18567403bca8a00c471b80dd7e0b5d539d4fd36c6ed256d2c9a5d461eb112
data/README.md CHANGED
@@ -2,13 +2,19 @@
2
2
 
3
3
  Write in Notion. Publish with Hugo.
4
4
 
5
+ Use Notion as a CMS (Content Management System) for your Hugo site/blog.
6
+
7
+ `hugo-notion` is a command line (CLI) tool that syncs your Notion page url to your Hugo site's/blog's `content` directory.
8
+
5
9
  ## Installation
6
10
 
11
+ `hugo-notion` is a Ruby gem. Use the `gem` command to install it
12
+
7
13
  ```
8
14
  gem install hugo-notion --prerelease
9
15
  ```
10
16
 
11
- Installing the `hugo-notion` ruby gem will install the `huno` command.
17
+ Installing the `hugo-notion` ruby gem will install the `huno` command
12
18
 
13
19
  ## Usage
14
20
 
data/bin/huno CHANGED
@@ -1,8 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'slop'
3
4
  require 'uri'
4
5
 
5
- env_file_path = File.join(Dir.pwd, '.env')
6
+ default_env_file_path = File.join(Dir.pwd, '.env')
7
+ opts = Slop.parse do |o|
8
+ o.integer '-r', '--repeat', default: 10
9
+ o.string '-e', '--env-file', default: default_env_file_path
10
+ end
11
+
12
+ env_file_path = opts[:env_file]
13
+ env_file_path = File.expand_path(env_file_path)
6
14
  if File.exist?(env_file_path)
7
15
  require 'dotenv'
8
16
  Dotenv.load(env_file_path)
@@ -12,8 +20,8 @@ unless notion_token
12
20
  throw "Please create a Notion integration, generate a secret and provide it in the 'NOTION_TOKEN' environment variable"
13
21
  end
14
22
 
15
- content_notion_url = if ARGV[0]
16
- ARGV[0]
23
+ content_notion_url = if opts.arguments[0]
24
+ opts.arguments[0]
17
25
  else
18
26
  ENV.fetch('CONTENT_NOTION_URL')
19
27
  end
@@ -23,23 +31,43 @@ end
23
31
  notion_page_id = URI(content_notion_url).path.match(/-(?<page_id>.*)\z/)['page_id']
24
32
 
25
33
  content_dir = File.join(Dir.pwd, 'content')
26
- if ARGV[1]
27
- content_dir = ARGV[1]
34
+ if opts.arguments[1]
35
+ content_dir = opts.arguments[1]
28
36
  elsif ENV['CONTENT_DIR']
29
37
  content_dir = ENV['CONTENT_DIR']
30
38
  end
31
39
  content_dir = File.expand_path(content_dir, Dir.pwd)
32
40
 
33
- require_relative '../lib/hugo_notion/synchronizer'
34
41
  def do_exit
35
42
  puts 'Exiting...'
36
43
  exit
37
44
  end
38
45
  Signal.trap("TERM") { do_exit }
39
46
  Signal.trap("INT") { do_exit }
40
- puts "Syncing content from Notion..."
41
- Synchronizer.run(
42
- notion_page_id: notion_page_id,
43
- destination_dir: content_dir
44
- )
45
- puts "Done."
47
+
48
+ require_relative '../lib/hugo_notion/synchronizer'
49
+
50
+ sync_content = Proc.new do
51
+ puts "Syncing content from Notion..."
52
+ Synchronizer.run(
53
+ notion_page_id: notion_page_id,
54
+ destination_dir: content_dir
55
+ )
56
+ puts "Done."
57
+ end
58
+
59
+ if opts.r?
60
+ loop do
61
+ begin
62
+ sync_content.call
63
+ sleep opts[:r]
64
+ rescue => e
65
+ puts "Sync failed."
66
+ puts e.message
67
+ puts e.backtrace
68
+ end
69
+ end
70
+ else
71
+ sync_content.call
72
+ exit
73
+ end
@@ -1,3 +1,3 @@
1
1
  class HugoNotion
2
- VERSION = '0.1.0-alpha.7'
2
+ VERSION = '0.1.0-alpha.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hugo-notion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.7
4
+ version: 0.1.0.pre.alpha.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nisanth Chunduru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: httparty
29
43
  requirement: !ruby/object:Gem::Requirement