From aebdce597e7716f618c2f7946a955a48cdc35fea Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 8 Oct 2024 18:48:42 +0200 Subject: [PATCH] Installer: Update demo files Use Tailwind from CDN instead of a compiling the article.css file into the host app. We do not know which css processor they are using and will not make any assumption. The demo fles will be removed anyway before going live and you can skip them with `--skip-demo-files`. --- .../alchemy/install/files/_article.html.erb | 10 +++++--- .../alchemy/install/files/alchemy.en.yml | 23 +++++++++++++++-- .../install/files/application.html.erb | 5 ++++ .../alchemy/install/files/article.css | 25 ------------------- .../alchemy/install/install_generator.rb | 14 +++-------- .../alchemy/install/templates/elements.yml.tt | 4 ++- 6 files changed, 39 insertions(+), 42 deletions(-) delete mode 100644 lib/generators/alchemy/install/files/article.css diff --git a/lib/generators/alchemy/install/files/_article.html.erb b/lib/generators/alchemy/install/files/_article.html.erb index 018de31ee8..cd58dd256a 100644 --- a/lib/generators/alchemy/install/files/_article.html.erb +++ b/lib/generators/alchemy/install/files/_article.html.erb @@ -1,7 +1,9 @@ <%- cache(article) do -%> - <%= element_view_for(article, tag: 'article') do |el| -%> -

<%= el.render :headline %>

- <%= el.render :picture, size: '1200x600' %> - <%= el.render :text %> + <%= element_view_for(article, tag: "article", class: "w-full max-w-xl mx-auto bg-slate-100 shadow my-8 px-8 py-4 rounded") do |el| -%> + <%= el.render :headline, {}, class: "text-2xl font-bold my-4" %> + <%= el.render :picture %> +
+ <%= el.render :text %> +
<%- end -%> <%- end -%> diff --git a/lib/generators/alchemy/install/files/alchemy.en.yml b/lib/generators/alchemy/install/files/alchemy.en.yml index 9757ebd0b1..7f9ef34283 100644 --- a/lib/generators/alchemy/install/files/alchemy.en.yml +++ b/lib/generators/alchemy/install/files/alchemy.en.yml @@ -17,11 +17,30 @@ en: # Default texts for new ingredients created default_ingredient_texts: article_headline: "Welcome to your first Alchemy CMS page" - article_text: '

How to get started.

First of all you should read about Alchemy and its architecture in the guidelines.

The most important things to know about Alchemy are elements and page layouts.

Elements:

With Alchemy you can split pages into content parts, elements. These elements can be defined out of several base content types: ingredients. The ingredients are:

Elements get defined in a YAML file config/alchemy/elements.yml

Read more about elements and how to define them in the guidelines.

Page types:

You can define several types of pages, called page layouts. You can assign elements to page layouts and control how elements and the page of a certain layout behave.

Page layouts get defined in a YAML file config/alchemy/page_layouts.yml

Read more about defining page layouts in the guidelines.

' + article_text: | +

How to get started.

+

First of all you should read about Alchemy and it's architecture in the guidelines.

+

The most important things to know about Alchemy are elements and page layouts.

+

Elements:

+

With Alchemy you can split pages into content parts, elements. These elements can be defined out of several base content types: ingredients. The ingredients are:

+ +

Elements get defined in config/alchemy/elements.yml.

+

Read more about elements and how to define them in the guidelines.

+

Page types:

+

You can define several types of pages, called page layouts. You can assign elements to page layouts and control how elements and the page of a certain layout behave.

+

Page layouts get defined in config/alchemy/page_layouts.yml.

+

Read more about defining page layouts in the guidelines.

# Hint texts for elements element_hints: - article: "This is a hint text for the article element. You can change this text in `config/locales/alchemy.en.yml`. Feel free to change it as you like, it's yours." + article: "This is a hint text for the article element. You can change this text in config/locales/alchemy.en.yml. Feel free to change it as you like, it's yours." # Hint texts for ingredients ingredient_hints: diff --git a/lib/generators/alchemy/install/files/application.html.erb b/lib/generators/alchemy/install/files/application.html.erb index 76f2a41d34..7584ab0485 100644 --- a/lib/generators/alchemy/install/files/application.html.erb +++ b/lib/generators/alchemy/install/files/application.html.erb @@ -7,6 +7,11 @@ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbo-track': 'reload' %> + + diff --git a/lib/generators/alchemy/install/files/article.css b/lib/generators/alchemy/install/files/article.css deleted file mode 100644 index 9adb19970c..0000000000 --- a/lib/generators/alchemy/install/files/article.css +++ /dev/null @@ -1,25 +0,0 @@ -article { - width: 50%; - font: 16px/20px Helvetica, Arial, sans-serif; - color: #333; - margin: 1em auto; - padding: 0.5em 1em; - background: #f4f4f4; -} -article h2 { - font-size: 24px; - line-height: 1.25; - font-weight: bold; -} -article a { - color: #5588D3; -} -article img { - max-width: 100%; -} -article figure { - margin: 0; -} -article figcaption { - font-size: 14px; -} diff --git a/lib/generators/alchemy/install/install_generator.rb b/lib/generators/alchemy/install/install_generator.rb index 04767d649c..90f0e2e435 100644 --- a/lib/generators/alchemy/install/install_generator.rb +++ b/lib/generators/alchemy/install/install_generator.rb @@ -65,22 +65,16 @@ def copy_yml_files def install_assets copy_file "custom.css", app_assets_path.join("stylesheets/alchemy/admin/custom.css") - append_to_file Rails.root.join("app/assets/config/manifest.js"), "//= link alchemy/admin/custom.css\n" + sprockets_manifest = Rails.root.join("app/assets/config/manifest.js") + if File.exist?(sprockets_manifest) + append_to_file sprockets_manifest, "//= link alchemy/admin/custom.css\n" + end end def copy_demo_views return if options[:skip_demo_files] copy_file "application.html.erb", app_views_path.join("layouts", "application.html.erb") - copy_file "article.css", app_assets_path.join("stylesheets", "alchemy", "elements", "_article.css") - - stylesheet_require = %(@import "alchemy/elements/article";\n) - if File.exist?(app_assets_path.join("stylesheets", "application.css")) - prepend_file app_assets_path.join("stylesheets", "application.css"), stylesheet_require - else - create_file app_assets_path.join("stylesheets", "application.css"), stylesheet_require - end - copy_file "_article.html.erb", app_views_path.join("alchemy", "elements", "_article.html.erb") copy_file "_standard.html.erb", app_views_path.join("alchemy", "page_layouts", "_standard.html.erb") copy_file "alchemy.en.yml", app_config_path.join("locales", "alchemy.en.yml") diff --git a/lib/generators/alchemy/install/templates/elements.yml.tt b/lib/generators/alchemy/install/templates/elements.yml.tt index dc4af8057e..5fd9595b15 100644 --- a/lib/generators/alchemy/install/templates/elements.yml.tt +++ b/lib/generators/alchemy/install/templates/elements.yml.tt @@ -8,12 +8,14 @@ unique: true ingredients: - role: headline - type: Text + type: Headline default: :article_headline hint: true - role: picture type: Picture hint: true + settings: + size: 1200x600 - role: text type: Richtext default: :article_text