mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Native theme support
This feature introduces the concept of themes. Themes are an evolution
of site customizations.
Themes introduce two very big conceptual changes:
- A theme may include other "child themes", children can include grand
children and so on.
- A theme may specify a color scheme
The change does away with the idea of "enabled" color schemes.
It also adds a bunch of big niceties like
- You can source a theme from a git repo
- History for themes is much improved
- You can only have a single enabled theme. Themes can be selected by
users, if you opt for it.
On a technical level this change comes with a whole bunch of goodies
- All CSS is now compiled using a custom pipeline that uses libsass
see /lib/stylesheet
- There is a single pipeline for css compilation (in the past we used
one for customizations and another one for the rest of the app
- The stylesheet pipeline is now divorced of sprockets, there is no
reliance on sprockets for CSS bundling
- CSS is generated with source maps everywhere (including themes) this
makes debugging much easier
- Our "live reloader" is smarter and avoid a flash of unstyled content
we run a file watcher in "puma" in dev so you no longer need to run
rake autospec to watch for CSS changes
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
class BreakUpThemesTable < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :theme_fields do |t|
|
||||
t.integer :theme_id, null: false
|
||||
t.integer :target, null: false
|
||||
t.string :name, null: false
|
||||
t.text :value, null: false
|
||||
t.text :value_baked
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :theme_fields, [:theme_id, :target, :name], unique: true
|
||||
|
||||
[
|
||||
[0, "embedded_scss", "embedded_scss"],
|
||||
[0, "common_scss", "scss"],
|
||||
[1, "desktop_scss", "scss"],
|
||||
[2, "mobile_scss", "scss"],
|
||||
[0, "head_tag", "head_tag"],
|
||||
[0, "body_tag", "body_tag"],
|
||||
[1, "header", "header"],
|
||||
[2, "mobile_header", "header"],
|
||||
[1, "top", "after_header"],
|
||||
[2, "mobile_top", "after_header"],
|
||||
[1, "footer", "footer"],
|
||||
[2, "mobile_footer", "footer"],
|
||||
].each do |target, value, name|
|
||||
|
||||
execute <<SQL
|
||||
INSERT INTO theme_fields (
|
||||
theme_id,
|
||||
target,
|
||||
name,
|
||||
value,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
SELECT id, #{target}, '#{name}', #{value}, created_at, updated_at
|
||||
FROM themes WHERE #{value} IS NOT NULL AND LENGTH(BTRIM(#{value})) > 0
|
||||
SQL
|
||||
remove_column :themes, value
|
||||
end
|
||||
|
||||
%w{ head_tag_baked
|
||||
body_tag_baked
|
||||
header_baked
|
||||
footer_baked
|
||||
mobile_footer_baked
|
||||
mobile_header_baked
|
||||
}.each do |col|
|
||||
remove_column :themes, col
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user