Current section
3 Versions
Jump to
Current section
3 Versions
Compare versions
17
files changed
+106
additions
-148
deletions
| @@ -12,9 +12,8 @@ | |
| 12 12 | <<"lib/lit/i18n/backend.ex">>,<<"lib/lit/views">>, |
| 13 13 | <<"lib/lit/views/page_view.ex">>,<<"lib/lit/views/flash_view.ex">>, |
| 14 14 | <<"lib/lit/views/table_view.ex">>,<<"lib/lit/views/filter_view.ex">>, |
| 15 | - <<"lib/lit/views/pagination_view.ex">>,<<"lib/lit/i18n.ex">>, |
| 16 | - <<"lib/lit_web">>,<<"lib/lit_web/live">>,<<"lib/lit_web/live/admin">>, |
| 17 | - <<"lib/mix">>,<<"lib/mix/tasks">>,<<"lib/mix/tasks/lit.uninstall.ex">>, |
| 15 | + <<"lib/lit/views/pagination_view.ex">>,<<"lib/lit/i18n.ex">>,<<"lib/mix">>, |
| 16 | + <<"lib/mix/tasks">>,<<"lib/mix/tasks/lit.uninstall.ex">>, |
| 18 17 | <<"lib/mix/tasks/lit.gen.live.ex">>,<<"lib/mix/tasks/lit.install.ex">>, |
| 19 18 | <<"lib/mix/tasks/lit.gen.html.ex">>,<<"lib/mix/lit.ex">>, |
| 20 19 | <<"lib/gettext.ex">>,<<"priv">>,<<"priv/gettext">>, |
| @@ -26,14 +25,12 @@ | |
| 26 25 | <<"priv/gettext/es/LC_MESSAGES">>, |
| 27 26 | <<"priv/gettext/es/LC_MESSAGES/default.po">>,<<"priv/gettext/en">>, |
| 28 27 | <<"priv/gettext/en/LC_MESSAGES">>, |
| 29 | - <<"priv/gettext/en/LC_MESSAGES/default.po">>,<<"priv/static">>, |
| 30 | - <<"priv/static/theme.css">>,<<"priv/static/down-arrow.png">>, |
| 31 | - <<"priv/static/lit.js">>,<<"priv/static/theme.css.map">>, |
| 32 | - <<"priv/static/base.css.map">>,<<"priv/static/lit-logo.png">>, |
| 33 | - <<"priv/static/lit.js.map">>,<<"priv/static/base.css">>, |
| 34 | - <<"priv/templates">>,<<"priv/templates/lit.install">>, |
| 28 | + <<"priv/gettext/en/LC_MESSAGES/default.po">>,<<"priv/templates">>, |
| 29 | + <<"priv/templates/lit.install">>, |
| 35 30 | <<"priv/templates/lit.install/pagination_component.ex">>, |
| 36 | - <<"priv/templates/slime">>,<<"priv/templates/slime/phx.gen.html">>, |
| 31 | + <<"priv/templates/lit.install/live.html.leex">>, |
| 32 | + <<"priv/templates/lit.install/layout_view.ex">>,<<"priv/templates/slime">>, |
| 33 | + <<"priv/templates/slime/phx.gen.html">>, |
| 37 34 | <<"priv/templates/slime/phx.gen.html/edit.html.slime">>, |
| 38 35 | <<"priv/templates/slime/phx.gen.html/index.html.slime">>, |
| 39 36 | <<"priv/templates/slime/phx.gen.html/form.html.slime">>, |
| @@ -105,4 +102,4 @@ | |
| 105 102 | {<<"optional">>,false}, |
| 106 103 | {<<"repository">>,<<"hexpm">>}, |
| 107 104 | {<<"requirement">>,<<"~> 3.1">>}]]}. |
| 108 | - {<<"version">>,<<"0.1.1">>}. |
| 105 | + {<<"version">>,<<"0.1.2">>}. |
| @@ -4,9 +4,10 @@ defmodule Mix.Lit do | |
| 4 4 | alias Lit.Config |
| 5 5 | |
| 6 6 | def parse_config!(task, args) do |
| 7 | - {opts, _, _} = OptionParser.parse(args, switches: [format: :string, app: :string]) |
| 7 | + {opts, _, _} = OptionParser.parse(args, switches: [default_web_namespace: :string, app: :string]) |
| 8 8 | |
| 9 | - format = convert_format(opts[:format] || Config.template_format()) |
| 9 | + # format = convert_format(opts[:format] || Config.template_format()) |
| 10 | + # default_web_namespace = opts[:default_web_namespace] || "Admin" |
| 10 11 | otp_app = opts[:app] || Config.otp_app() |
| 11 12 | |
| 12 13 | unless otp_app do |
| @@ -21,23 +22,23 @@ defmodule Mix.Lit do | |
| 21 22 | mix #{task} --app my_app |
| 22 23 | """) |
| 23 24 | end |
| 25 | + # |
| 26 | + # unless format in ["eex", "slime"] do |
| 27 | + # Mix.raise(""" |
| 28 | + # Template format is invalid: #{inspect(format)}. Either configure it as |
| 29 | + # shown below or pass it via the `--format` option. |
| 30 | + # |
| 31 | + # config :lit, |
| 32 | + # template_format: :slime |
| 33 | + # |
| 34 | + # # Alternatively |
| 35 | + # mix #{task} --format slime |
| 36 | + # |
| 37 | + # Supported formats: eex, slime |
| 38 | + # """) |
| 39 | + # end |
| 24 40 | |
| 25 | - unless format in ["eex", "slime"] do |
| 26 | - Mix.raise(""" |
| 27 | - Template format is invalid: #{inspect(format)}. Either configure it as |
| 28 | - shown below or pass it via the `--format` option. |
| 29 | - |
| 30 | - config :lit, |
| 31 | - template_format: :slime |
| 32 | - |
| 33 | - # Alternatively |
| 34 | - mix #{task} --format slime |
| 35 | - |
| 36 | - Supported formats: eex, slime |
| 37 | - """) |
| 38 | - end |
| 39 | - |
| 40 | - %{otp_app: otp_app, format: format} |
| 41 | + %{otp_app: otp_app, default_web_namespace: "Admin"} |
| 41 42 | end |
| 42 43 | |
| 43 44 | def ensure_phoenix_is_loaded!(mix_task \\ "task") do |
| @@ -74,13 +75,13 @@ defmodule Mix.Lit do | |
| 74 75 | This is why this function invocation of `copy_from/2` changes the template file extensions |
| 75 76 | to `.html.eex` reglardess of the original template format type. |
| 76 77 | """ |
| 77 | - def inject_templates("phx.gen.html", format) do |
| 78 | - copy_from("priv/templates/#{format}/phx.gen.html", [ |
| 79 | - {"edit.html.#{format}", "priv/templates/phx.gen.html/edit.html.eex"}, |
| 80 | - {"form.html.#{format}", "priv/templates/phx.gen.html/form.html.eex"}, |
| 81 | - {"index.html.#{format}", "priv/templates/phx.gen.html/index.html.eex"}, |
| 82 | - {"new.html.#{format}", "priv/templates/phx.gen.html/new.html.eex"}, |
| 83 | - {"show.html.#{format}", "priv/templates/phx.gen.html/show.html.eex"} |
| 78 | + def inject_templates("phx.gen.html", _format) do |
| 79 | + copy_from("priv/templates/eex/phx.gen.html", [ |
| 80 | + {"edit.html.eex", "priv/templates/phx.gen.html/edit.html.eex"}, |
| 81 | + {"form.html.eex", "priv/templates/phx.gen.html/form.html.eex"}, |
| 82 | + {"index.html.eex", "priv/templates/phx.gen.html/index.html.eex"}, |
| 83 | + {"new.html.eex", "priv/templates/phx.gen.html/new.html.eex"}, |
| 84 | + {"show.html.eex", "priv/templates/phx.gen.html/show.html.eex"} |
| 84 85 | ]) |
| 85 86 | |
| 86 87 | copy_from("priv/templates/common/phx.gen.html", [ |
| @@ -125,7 +126,7 @@ defmodule Mix.Lit do | |
| 125 126 | def remove_templates(template_dir) do |
| 126 127 | File.rm_rf("priv/templates/#{template_dir}/") |
| 127 128 | end |
| 128 | - |
| 129 | - defp convert_format("slim"), do: "slime" |
| 130 | - defp convert_format(format), do: format |
| 129 | + # |
| 130 | + # defp convert_format("slim"), do: "slime" |
| 131 | + # defp convert_format(format), do: format |
| 131 132 | end |
| @@ -17,9 +17,9 @@ defmodule Mix.Tasks.Lit.Gen.Live do | |
| 17 17 | Mix.raise("mix lit.gen.live can only be run inside an application directory") |
| 18 18 | end |
| 19 19 | |
| 20 | - IO.inspect(args) # ["Posts", "Post", "posts", "--web", "Admin", "title"] |
| 20 | + # IO.inspect(args) # ["Posts", "Post", "posts", "--web", "Admin", "title"] |
| 21 21 | |
| 22 | - %{format: format} = Mix.Lit.parse_config!("lit.gen.live", args) |
| 22 | + %{default_web_namespace: _default_web_namespace} = Mix.Lit.parse_config!("lit.gen.live", args) |
| 23 23 | |
| 24 24 | Mix.Lit.ensure_phoenix_is_loaded!("lit.gen.live") |
| 25 25 | |
| @@ -28,7 +28,7 @@ defmodule Mix.Tasks.Lit.Gen.Live do | |
| 28 28 | |
| 29 29 | # Inject the lit templates for the generator into the priv/ |
| 30 30 | # directory so they will be picked up by the Phoenix generator |
| 31 | - Enum.each(@commands, &Mix.Lit.inject_templates(&1, format)) |
| 31 | + Enum.each(@commands, &Mix.Lit.inject_templates(&1, "eex")) |
| 32 32 | |
| 33 33 | # Run the Phoenix generator |
| 34 34 | Mix.Task.run("phx.gen.live", args) |
| @@ -40,24 +40,22 @@ defmodule Mix.Tasks.Lit.Gen.Live do | |
| 40 40 | # Restore the projects existing templates if present |
| 41 41 | Enum.each(@commands, &Mix.Lit.restore_project_templates/1) |
| 42 42 | |
| 43 | - # Mix.shell().info(""" |
| 44 | - # Ensure the following is added to your endpoint.ex: |
| 45 | - # |
| 46 | - # plug( |
| 47 | - # Plug.Static, |
| 48 | - # at: "/lit", |
| 49 | - # from: {:lit, "priv/static"}, |
| 50 | - # gzip: true, |
| 51 | - # cache_control_for_etags: "public, max-age=86400", |
| 52 | - # headers: [{"access-control-allow-origin", "*"}] |
| 53 | - # ) |
| 54 | - # """) |
| 43 | + {context, schema} = Mix.Tasks.Phx.Gen.Context.build(args) |
| 44 | + |
| 45 | + Mix.shell().info(""" |
| 46 | + Ensure the following is added to your router.ex: |
| 47 | + |
| 48 | + pipeline :admin_layout do |
| 49 | + plug :put_root_layout, {#{context.web_module}.#{schema.web_namespace}.LayoutView, :lit} |
| 50 | + end |
| 51 | + """) |
| 55 52 | |
| 56 53 | Mix.shell().info(""" |
| 57 54 | Also don't forget to add a link to layouts/lit.html. |
| 58 55 | |
| 59 | - <nav class="lit-nav"> |
| 60 | - <!-- nav links here --> |
| 56 | + <nav id="nav-links"> |
| 57 | + <!-- ADD NAVIGATION LINKS HERE --> |
| 58 | + <a class="py-1 my-1 text-sm font-medium text-gray-700 md:py-0 hover:text-blue-400 focus:outline-none md:mx-3 md:my-0" href="#">Home</a> |
| 61 59 | </nav> |
| 62 60 | """) |
| 63 61 | end |
| @@ -25,14 +25,14 @@ defmodule Mix.Tasks.Lit.Install do | |
| 25 25 | Mix.raise("mix lit.install can only be run inside an application directory") |
| 26 26 | end |
| 27 27 | |
| 28 | - %{format: format, otp_app: otp_app} = Mix.Lit.parse_config!("lit.install", args) |
| 28 | + %{default_web_namespace: _default_web_namespace, otp_app: otp_app} = Mix.Lit.parse_config!("lit.install", args) |
| 29 29 | |
| 30 30 | Mix.Lit.ensure_phoenix_is_loaded!("lit.install") |
| 31 31 | |
| 32 32 | phoenix_version = Application.spec(:phoenix, :vsn) |
| 33 33 | |
| 34 | - Mix.Lit.copy_from("priv/templates/#{format}", [ |
| 35 | - {template_file(phoenix_version, format), |
| 34 | + Mix.Lit.copy_from("priv/templates/eex", [ |
| 35 | + {template_file(phoenix_version, "eex"), |
| 36 36 | "lib/#{otp_app}_web/templates/admin/layout/lit.html.leex"} |
| 37 37 | ]) |
| 38 38 | |
| @@ -58,6 +58,8 @@ defmodule Mix.Tasks.Lit.Install do | |
| 58 58 | |
| 59 59 | files = [ |
| 60 60 | {:eex, "pagination_component.ex", Path.join([web_prefix, "live", "admin", "common", "pagination_component.ex"])}, |
| 61 | + {:eex, "live.html.leex", Path.join([web_prefix, "templates", "admin", "layout", "live.html.leex"])}, |
| 62 | + {:eex, "layout_view.ex", Path.join([web_prefix, "views", "admin", "layout_view.ex"])}, |
| 61 63 | ] |
| 62 64 | |
| 63 65 | Mix.Phoenix.copy_from([:lit], "priv/templates/lit.install", binding, files) |
| @@ -12,10 +12,10 @@ defmodule Mix.Tasks.Lit.Uninstall do | |
| 12 12 | Mix.raise("mix lit.uninstall can only be run inside an application directory") |
| 13 13 | end |
| 14 14 | |
| 15 | - %{format: format, otp_app: otp_app} = Mix.Lit.parse_config!("lit.uninstall", args) |
| 15 | + %{default_web_namespace: default_web_namespace, otp_app: otp_app} = Mix.Lit.parse_config!("lit.uninstall", args) |
| 16 16 | |
| 17 17 | paths = [ |
| 18 | - "lib/#{otp_app}_web/templates/layout/lit.html.#{format}" |
| 18 | + "lib/#{otp_app}_web/templates/#{default_web_namespace}/layout/lit.html.leex" |
| 19 19 | ] |
| 20 20 | |
| 21 21 | Enum.each(paths, &File.rm/1) |
Loading more files…