Installa l'app console Discourse Theme CLI per aiutarti a creare temi

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 Mi Piace

Uploads tramite Admin >> Personalizza >> Temi scompaiono dopo il salvataggio di un tema osservato.

Come includiamo gli asset di immagine nel tema in modo che non vengano eliminati dopo il salvataggio?

2 Mi Piace

Ciao, benvenuto!

Devi includere gli asset direttamente nel tuo componente del tema.
Alla radice, crei una directory assets.
Quindi, li dichiari in about.json

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

Puoi vedere un esempio qui GitHub - MeghnaAJ/discourse-christmas-decorations.

3 Mi Piace

Un breve avviso per gli sviluppatori che utilizzano questo strumento per generare componenti del tema:
Si incoraggia l’aggiornamento! :+1:

Una recente PR ha reso il repository discourse-theme-skeleton il modello predefinito. Ti fornirà i file di configurazione più recenti!

9 Mi Piace

Grazie!

Sarebbe fantastico aggiungere una sezione Aggiornamento all’argomento…

È un aggiornamento --reset o un aggiornamento rubygem?

4 Mi Piace

Ottima idea! Ho aggiunto una sezione ‘aggiornamento’ all’OP

gem update discourse_theme
5 Mi Piace

Per installare la gemma su WSL, ho dovuto eseguire sia sudo apt-get install ruby che sudo apt-get install ruby-dev.
Forse questo può essere aggiunto alle istruzioni di installazione.

Se non installi ruby-dev, ottieni un errore? Non dovrebbe essere necessario installare ruby-dev poiché ruby da solo è sufficiente.

4 Mi Piace

Sono abbastanza sicuro di aver ricevuto un errore che mi diceva di installare ruby-dev, altrimenti non avrei saputo che il pacchetto esistesse.
Ma non riesco a riprodurlo provando a reinstallarlo. Forse ho fatto qualcosa di strano la prima volta.

2 Mi Piace

Hmm, è davvero strano. Sentiti libero di farmelo sapere se riesci a riprodurre di nuovo il problema.

2 Mi Piace

Ho aggiornato il mio server ieri a 3.5.0.beta9-dev e non ottengo più i live reload con il discourse theme gem. La gem è alla versione 2.1.6.

Non vedo errori o altro, quindi volevo prima chiedere se qualcun altro ha lo stesso problema?

1 Mi Piace

I ricaricamenti in tempo reale degli stylesheet sono stati disabilitati per le istanze di produzione, poiché causavano problemi durante l’aggiornamento di temi e/o del core di Discourse.

Fondamentalmente: le modifiche agli stylesheet sono spesso legate a modifiche in JS/HTML, quindi il caricamento in tempo reale solo per gli stylesheet è rischioso. Gli utenti finiscono per eseguire “nuovi” stylesheet contro HTML “vecchio”, il che può portare a esperienze molto strane.

Il caricamento in tempo reale è ancora abilitato per le istanze di Discourse in modalità di sviluppo. Idealmente, dovresti usarlo per lo sviluppo piuttosto che per un sito di produzione. Oltre al ricaricamento degli stylesheet, la modalità di sviluppo di Ember ti offre messaggi di errore molto più amichevoli rispetto alla modalità di produzione di Ember.

3 Mi Piace

È un grande cambiamento. Sono sorpreso che non ci sia stato un annuncio. Avevo sviluppato temi principalmente solo su siti di produzione.

Una impostazione del sito per ottenere il vecchio comportamento potrebbe essere utile.

4 Mi Piace

Concordo, questo mi ha sorpreso e non sono riuscito a trovare questo thread attuale nonostante la ricerca, o forse ho visto la data della OP precedente e l’ho ignorata.