discourse_theme 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/discourse_theme/cli.rb +13 -1
- data/lib/discourse_theme/client.rb +2 -1
- data/lib/discourse_theme/config.rb +8 -0
- data/lib/discourse_theme/uploader.rb +3 -2
- data/lib/discourse_theme/version.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed19147c8208315a736b690c90e072986604c9c4fd7c10b05b42dc7dfeb8b400
|
4
|
+
data.tar.gz: 75553d2685a0ee8c3083c73e11d449a6bedefc36b6212b432cd488b8882cbb1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59603310b69ea2702828ac5a79ef74da0d091dfbd5cf7d5184b8f1943198a72446b9ebbcd243f9f05d6f89ea7de192f7f49c9a434cc4d95bff51a4794f1a286e
|
7
|
+
data.tar.gz: a45dc46ff96d8bd1a9fcffb6d4757e38908bd8e43e4a9e641c32c3458061ccfc15bc3855c65026c2b13fbff0b3e9b90f53c9243c80511c7c51a3877c7a9d02e2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Discourse Theme
|
2
2
|
|
3
|
-
This CLI contains helpers for creating [Discourse themes](https://meta.discourse.org/c/theme).
|
3
|
+
This CLI contains helpers for creating [Discourse themes](https://meta.discourse.org/c/theme) and theme components.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -10,7 +10,7 @@ To install the CLI use:
|
|
10
10
|
|
11
11
|
## Why this gem exists?
|
12
12
|
|
13
|
-
This gem allows you to use your editor of choice when developing Discourse themes. As you save files the CLI will update the remote theme and changes to it will appear live!
|
13
|
+
This gem allows you to use your editor of choice when developing Discourse themes and theme components. As you save files the CLI will update the remote theme or component and changes to it will appear live!
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
@@ -24,7 +24,7 @@ it contains two helpers:
|
|
24
24
|
|
25
25
|
You can use `discourse_theme new PATH` to crate a new blank theme, the CLI will guide you through the process.
|
26
26
|
|
27
|
-
You can use `discourse_theme watch PATH` to monitor your theme for changes, when changed the program will synchronize the theme to your Discourse of choice.
|
27
|
+
You can use `discourse_theme watch PATH` to monitor your theme or component for changes, when changed the program will synchronize the theme or component to your Discourse of choice.
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
data/lib/discourse_theme/cli.rb
CHANGED
@@ -57,6 +57,7 @@ module DiscourseTheme
|
|
57
57
|
settings = config[dir]
|
58
58
|
|
59
59
|
theme_id = settings.theme_id
|
60
|
+
components = settings.components
|
60
61
|
|
61
62
|
if command == "new"
|
62
63
|
raise DiscourseTheme::ThemeError.new "'#{dir} is not empty" if Dir.exists?(dir) && !Dir.empty?(dir)
|
@@ -87,9 +88,20 @@ module DiscourseTheme
|
|
87
88
|
themes = render_theme_list(theme_list)
|
88
89
|
choice = Cli.select('Which theme would you like to sync with?', themes)
|
89
90
|
theme_id = extract_theme_id(choice)
|
91
|
+
theme = theme_list.find { |t| t["id"] == theme_id }
|
90
92
|
end
|
91
93
|
|
92
|
-
|
94
|
+
if !theme || theme["component"] == false
|
95
|
+
options = {}
|
96
|
+
options["Add missing but leave all extra components as is"] = :add
|
97
|
+
options["Add missing and remove superfluous"] = :sync
|
98
|
+
options["Do nothing"] = :none
|
99
|
+
options = options.sort_by { |_, b| b == components.to_sym ? 0 : 1 }.to_h if components
|
100
|
+
choice = Cli.select('How would you like to update child theme components?', options.keys)
|
101
|
+
settings.components = components = options[choice].to_s
|
102
|
+
end
|
103
|
+
|
104
|
+
uploader = DiscourseTheme::Uploader.new(dir: dir, client: client, theme_id: theme_id, components: components)
|
93
105
|
|
94
106
|
Cli.progress "Uploading theme from #{dir}"
|
95
107
|
settings.theme_id = theme_id = uploader.upload_full_theme
|
@@ -79,7 +79,7 @@ module DiscourseTheme
|
|
79
79
|
request(put)
|
80
80
|
end
|
81
81
|
|
82
|
-
def upload_full_theme(tgz, theme_id:)
|
82
|
+
def upload_full_theme(tgz, theme_id:, components:)
|
83
83
|
endpoint = root +
|
84
84
|
if @is_theme_creator
|
85
85
|
"/user_themes/import.json"
|
@@ -90,6 +90,7 @@ module DiscourseTheme
|
|
90
90
|
post = Net::HTTP::Post::Multipart.new(
|
91
91
|
endpoint,
|
92
92
|
"theme_id" => theme_id,
|
93
|
+
"components" => components,
|
93
94
|
"bundle" => UploadIO.new(tgz, "application/tar+gzip", "bundle.tar.gz")
|
94
95
|
)
|
95
96
|
request(post)
|
@@ -3,10 +3,11 @@ module DiscourseTheme
|
|
3
3
|
|
4
4
|
THEME_CREATOR_REGEX = /^https:\/\/theme-creator.discourse.org$/i
|
5
5
|
|
6
|
-
def initialize(dir:, client:, theme_id: nil)
|
6
|
+
def initialize(dir:, client:, theme_id: nil, components: nil)
|
7
7
|
@dir = dir
|
8
8
|
@client = client
|
9
9
|
@theme_id = theme_id
|
10
|
+
@components = components
|
10
11
|
end
|
11
12
|
|
12
13
|
def compress_dir(gzip, dir)
|
@@ -66,7 +67,7 @@ module DiscourseTheme
|
|
66
67
|
compress_dir(filename, @dir)
|
67
68
|
|
68
69
|
File.open(filename) do |tgz|
|
69
|
-
response = @client.upload_full_theme(tgz, theme_id: @theme_id)
|
70
|
+
response = @client.upload_full_theme(tgz, theme_id: @theme_id, components: @components)
|
70
71
|
|
71
72
|
json = JSON.parse(response.body)
|
72
73
|
@theme_id = json["theme"]["id"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|