discourse_theme 0.5.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a594e3cf6429ad7b721ca546710a1f57706a74bb0c8346301dea8b76a58cea
4
- data.tar.gz: 477808a79184cc9251865a86a77ccfa33a64318a90a774207a5441b683499546
3
+ metadata.gz: ddb3a33c31b31e4e097467e73fb6ad83a48b5260ab254043529f0ba0066cee06
4
+ data.tar.gz: 6db1a2ad3ab1a47fc479250dbcb03aaa21600791ff0cce49eb477be3a43fbcdb
5
5
  SHA512:
6
- metadata.gz: 8d5ad9c41ca00b3172167b1985cdb5da36ef6d8073ad6b4882f6760da05006f550a12447007d64fb8486e078245eab618979c80e18e78eaa4cc1487269dd780a
7
- data.tar.gz: 7e40d9ec1727422c4875307b35b38a3d178330598c4a0b1c207779564fe8cf4dbbd07864e964e8e7eee1d5ffec47ad9cdc2821f28fd24ebe1bdb44677cd659cf
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.
@@ -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.discourse.org$/i
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)
@@ -47,7 +47,11 @@ module DiscourseTheme
47
47
 
48
48
  ESLINT_RC = <<~STR
49
49
  {
50
- "extends": "eslint-config-discourse"
50
+ "extends": "eslint-config-discourse",
51
+ "globals": {
52
+ "settings": "readonly",
53
+ "themePrefix": "readonly"
54
+ }
51
55
  }
52
56
  STR
53
57
 
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module DiscourseTheme
3
3
  class Uploader
4
-
5
- THEME_CREATOR_REGEX = /^https:\/\/theme-creator.discourse.org$/i
6
-
7
4
  def initialize(dir:, client:, theme_id: nil, components: nil)
8
5
  @dir = dir
9
6
  @client = client
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module DiscourseTheme
3
- VERSION = "0.5.2"
3
+ VERSION = "0.7.1"
4
4
  end
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.5.2
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: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitar