Install the Discourse Theme CLI console app to help you build themes

The discourse Discourse Theme CLI is a ruby gem that 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!

Installing

To play with it, make sure you have Ruby 2.5 or up installed.

If you are on Windows, you have 2 options:

Option 1: Windows Subsystem for Linux.

Windows 10 has access to a full Linux environment, you can use it to install ruby simply with sudo apt-get install ruby, this will give you Ruby 2.3.

Options 2: Older Windows

Older versions of Windows have no access to WSL, you can easily install Ruby with Ruby Installer, go for the recommended version and default settings for the install.

Mac OS version 10.13.3 ship with Ruby 2.3 out of the box, nothing special is needed. If you are running an earlier version of Mac OS consider using rvm, rbenv or homebrew to install a recent ruby.


Once Ruby 2.2 or later is running, open a terminal or command shell and run:

gem install discourse_theme

Once installed, to learn more about it:

discourse_theme

Upgrading

gem update discourse_theme

Features

The CLI provides 3 main functions:

discourse_theme new

You can use it to quickly create a new theme with discourse_theme new YOUR_DIR_NAME

discourse_theme watch

You can use it to monitor a theme and synchronize with a discourse site (with live refresh) using discourse_theme watch YOUR_DIR_NAME

What this means is that you can use your own editor to edit you theme and site will magically :unicorn: update with the changes!

discourse_theme download

You can download an existing theme from Discourse using discourse_theme download YOUR_DIR_NAME. You will then be given the option to start “watching” straight away!

Credentials

You will need to generate an API Key. Go to the admin area and generate a key there.

  • :exclamation: Select a “User Level” of Single User when generating the key, not All Users.
  • :exclamation: Make sure to check Global Key or you will receive 403 forbidden errors.

Credentials are (optionally) stored at ~/.discourse_theme. API keys are stored per-site, and the URL/theme_id for each directory is also tracked. If you ever need to change your settings, just add --reset to any command and you will be prompted for all values again.

Testimonials

“This tool is truly a GEM!” @awole20
“This is very very good.” @awesomerobot
“It’s working :slight_smile: And it’s pretty dosh garn cool. Nice!” @angus
“OMG. It’s unbelievable.” @pfaffman


This document is version controlled - suggest changes on github.

「いいね!」 79

Admin の Uploads > > Customize > > Themes で、ウォッチ中のテーマを保存すると消えてしまいます。

保存後に消えないように、テーマに画像アセットを含めるにはどうすればよいですか?

「いいね!」 2

こんにちは、ようこそ!

アセットはテーマコンポーネントに直接含める必要があります。
ルートに assets ディレクトリを作成します。
次に、about.json で宣言します。

"assets": {
  "<your_identifier>": "assets/<your_asset_filename>",
}

例はこちらで確認できます。https://github.com/MeghnaAJ/discourse-christmas-decorations。

「いいね!」 3

このツールを使用してテーマコンポーネントを生成している開発者の皆様へ:

アップグレードを推奨します! :+1:

最近のPRにより、discourse-theme-skeletonリポジトリがデフォルトのテンプレートになりました。これにより、最新の設定ファイルを利用できます!

「いいね!」 9

ありがとうございます。

トピックに「更新」セクションを追加していただけると幸いです…

これは --reset ですか、それとも rubygem update ですか?

「いいね!」 4

良いアイデアですね!OPに「アップグレード」セクションを追加しました。

gem update discourse_theme
「いいね!」 5

WSLにgemをインストールするには、sudo apt-get install rubysudo apt-get install ruby-devの両方を実行する必要がありました。
インストール手順に追加できるかもしれません。

ruby-dev をインストールしない場合、エラーが発生しますか? ruby 自体で十分なので、ruby-dev をインストールする必要はないはずです。

「いいね!」 4

ruby-dev をインストールするようにというエラーメッセージが表示されたので、そのパッケージの存在を知ることができました。しかし、再インストールを試みても再現できません。もしかしたら、初回は何かおかしな操作をしたのかもしれません。

「いいね!」 2

それは確かに奇妙ですね。問題が再び再現された場合は、お気軽にお知らせください。

「いいね!」 2

サーバーを昨日3.5.0.beta9-devにアップデートしたのですが、それ以来、Discourseテーマgemでライブリロードができなくなりました。Gemのバージョンは2.1.6です。

エラーなどは何も表示されないので、まず同じような問題が発生している人がいないか質問したいと思いました。

「いいね!」 1

本番環境では、テーマやDiscourseコアの更新時に問題が発生する可能性があるため、スタイルシートのライブリロードが無効になりました

根本的に、スタイルシートの変更はJS/HTMLの変更と密接に関連していることが多いため、スタイルシートのみのライブロードは危険です。ユーザーは「新しい」スタイルシートを「古い」HTMLに対して実行することになり、非常に奇妙な体験につながる可能性があります。

開発モードのDiscourseインスタンスでは、ライブロードは引き続き有効です。理想的には、本番サイトではなく開発に使用してください。スタイルシートのリロード以外にも、開発モードのEmberは本番モードのEmberよりもはるかにわかりやすいエラーメッセージを提供します。

「いいね!」 3

これは大きな変更ですね。告知がなかったことに驚いています。私は主に本番サイトでテーマ開発を行っていました。

以前の動作を再現するためのサイト設定があると良いかもしれません。

「いいね!」 4

確かに、これは驚きました。検索してもこのスレッドが見つからなかったか、あるいは古いOPの日付を見て無視したのかもしれません。