discourse_theme 0.5.2 → 0.7.1
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/README.md +4 -0
- data/lib/discourse_theme/cli.rb +23 -0
- data/lib/discourse_theme/client.rb +8 -2
- data/lib/discourse_theme/scaffold.rb +5 -1
- data/lib/discourse_theme/uploader.rb +0 -3
- data/lib/discourse_theme/version.rb +1 -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: ddb3a33c31b31e4e097467e73fb6ad83a48b5260ab254043529f0ba0066cee06
|
4
|
+
data.tar.gz: 6db1a2ad3ab1a47fc479250dbcb03aaa21600791ff0cce49eb477be3a43fbcdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8acd7de25b128b86d5dff6852aaf89607bd61ef164d0b80fdc983768bc42b47bd2a6583958ca7a5df97467eae1306f1dbaf4b92a483c77698bb06d521fc824f
|
7
|
+
data.tar.gz: 98e8745391c850e49fa5bd1ccee0dabfe6ee2fe3c6584ec49f108360887e51e31036a3115ce08e926c8e279dc642d520406523babb32aa28ba048efa34d8ca8d
|
data/README.md
CHANGED
@@ -32,6 +32,10 @@ Downloads a theme from the server and stores in the designated directory.
|
|
32
32
|
|
33
33
|
Monitors a theme or component for changes. When changed the program will synchronize the theme or component to your Discourse of choice.
|
34
34
|
|
35
|
+
### `discourse_theme upload PATH`
|
36
|
+
|
37
|
+
Uploads a theme to the server. Requires the theme to have been previously synchronized via `watch`.
|
38
|
+
|
35
39
|
## Contributing
|
36
40
|
|
37
41
|
Bug reports and pull requests are welcome at [Meta Discourse](https://meta.discourse.org). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/discourse_theme/cli.rb
CHANGED
@@ -8,6 +8,7 @@ module DiscourseTheme
|
|
8
8
|
puts
|
9
9
|
puts "discourse_theme new DIR - Creates a new theme in the designated directory"
|
10
10
|
puts "discourse_theme download DIR - Downloads a theme from the server and stores in the designated directory"
|
11
|
+
puts "discourse_theme upload DIR - Uploads the theme directory to Discourse"
|
11
12
|
puts "discourse_theme watch DIR - Watches the theme directory and synchronizes with Discourse"
|
12
13
|
puts
|
13
14
|
puts "Use --reset to change the configuration for a directory"
|
@@ -110,6 +111,28 @@ module DiscourseTheme
|
|
110
111
|
UI.success "Theme downloaded"
|
111
112
|
|
112
113
|
watch_theme?(args)
|
114
|
+
elsif command == "upload"
|
115
|
+
raise DiscourseTheme::ThemeError.new "'#{dir} does not exist" unless Dir.exists?(dir)
|
116
|
+
raise DiscourseTheme::ThemeError.new "No theme_id is set, please sync via the 'watch' command initially" if theme_id == 0
|
117
|
+
client = DiscourseTheme::Client.new(dir, settings, reset: reset)
|
118
|
+
|
119
|
+
theme_list = client.get_themes_list
|
120
|
+
|
121
|
+
theme = theme_list.find { |t| t["id"] == theme_id }
|
122
|
+
raise DiscourseTheme::ThemeError.new "theme_id is set, but the theme does not exist in Discourse" unless theme
|
123
|
+
|
124
|
+
uploader = DiscourseTheme::Uploader.new(dir: dir, client: client, theme_id: theme_id, components: components)
|
125
|
+
|
126
|
+
UI.progress "Uploading theme (id:#{theme_id}) from #{dir} "
|
127
|
+
settings.theme_id = theme_id = uploader.upload_full_theme
|
128
|
+
|
129
|
+
UI.success "Theme uploaded (id:#{theme_id})"
|
130
|
+
UI.info "Preview: #{client.root}/?preview_theme_id=#{theme_id}"
|
131
|
+
if client.is_theme_creator
|
132
|
+
UI.info "Manage: #{client.root}/my/themes"
|
133
|
+
else
|
134
|
+
UI.info "Manage: #{client.root}/admin/customize/themes/#{theme_id}"
|
135
|
+
end
|
113
136
|
else
|
114
137
|
usage
|
115
138
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module DiscourseTheme
|
3
3
|
class Client
|
4
|
-
THEME_CREATOR_REGEX = /^https:\/\/theme-creator
|
4
|
+
THEME_CREATOR_REGEX = /^https:\/\/(theme-creator\.discourse\.org|discourse\.theme-creator\.io)$/i
|
5
5
|
|
6
6
|
def initialize(dir, settings, reset:)
|
7
7
|
@reset = reset
|
@@ -105,7 +105,7 @@ module DiscourseTheme
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def root
|
108
|
-
@url
|
108
|
+
URI.parse(@url).path
|
109
109
|
end
|
110
110
|
|
111
111
|
def is_theme_creator
|
@@ -116,6 +116,12 @@ module DiscourseTheme
|
|
116
116
|
|
117
117
|
def request(request, never_404: false)
|
118
118
|
uri = URI.parse(@url)
|
119
|
+
|
120
|
+
if uri.userinfo
|
121
|
+
username, password = uri.userinfo.split(":", 2)
|
122
|
+
request.basic_auth username, password
|
123
|
+
end
|
124
|
+
|
119
125
|
http = Net::HTTP.new(uri.host, uri.port)
|
120
126
|
http.use_ssl = URI::HTTPS === uri
|
121
127
|
add_headers(request)
|
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.
|
4
|
+
version: 0.7.1
|
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: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitar
|