From c792485b48a7169501bf75da9980651f2c2d578e Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 15 Jan 2025 18:44:34 -0500 Subject: [PATCH] WIP --- assets/js/app.js | 8 + assets/tailwind.config.js | 2 +- .../post_processors/highlighter.ex | 171 --------------- lib/ash_hq_web/controllers/home_controller.ex | 14 ++ lib/ash_hq_web/pages/community.ex | 8 - lib/ash_hq_web/router.ex | 27 +-- .../templates/home/community.html.heex | 197 ++++++++++++++++++ lib/ash_hq_web/templates/home/home.html.heex | 177 +++++----------- lib/ash_hq_web/templates/home/media.html.heex | 70 +++++++ lib/ash_hq_web/templates/layout/app.html.heex | 38 ++++ .../templates/layout/root.html.heex | 4 +- mix.exs | 1 - 12 files changed, 399 insertions(+), 318 deletions(-) create mode 100644 lib/ash_hq_web/templates/home/community.html.heex create mode 100644 lib/ash_hq_web/templates/home/media.html.heex diff --git a/assets/js/app.js b/assets/js/app.js index d828eb5..4039204 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -524,6 +524,14 @@ window.cantDecide = function() { el.classList.add("hidden") }); + [...document.querySelectorAll(".active-quickstart")].forEach((el) => { + if(!el.classList.contains("hidden")) { + el.click(); + } + }); + + document.getElementById("quickstart-live_view-inactive").click() + document.getElementById("show-options").classList.remove("hidden"); document.getElementById("dont-worry").classList.remove("hidden"); } diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index 4af1573..3c2953b 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -6,7 +6,7 @@ const fs = require("fs") const path = require("path") module.exports = { - darkMode: "selector", + darkMode: "class", content: [ "./js/**/*.js", "../lib/*_web/**/*.*ex", diff --git a/lib/ash_hq/docs/extensions/render_markdown/post_processors/highlighter.ex b/lib/ash_hq/docs/extensions/render_markdown/post_processors/highlighter.ex index 51b4330..4425045 100644 --- a/lib/ash_hq/docs/extensions/render_markdown/post_processors/highlighter.ex +++ b/lib/ash_hq/docs/extensions/render_markdown/post_processors/highlighter.ex @@ -7,176 +7,5 @@ defmodule AshHq.Docs.Extensions.RenderMarkdown.PostProcessors.Highlighter do def highlight(ast, libraries, current_library, _current_module) do ast - |> Floki.traverse_and_update(fn - {"a", attrs, contents} -> - {"a", rewrite_href_attr(attrs, current_library, libraries), contents} - - {"pre", _, [{:keep, contents}]} -> - {:keep, ~s(
#{contents}
)} - - {"pre", _, [{"code", attrs, [body]}]} when is_binary(body) -> - lexer = - find_value_class(attrs, fn class -> - case Makeup.Registry.fetch_lexer_by_name(class) do - {:ok, {lexer, opts}} -> {class, lexer, opts} - :error -> nil - end - end) - - code = - case lexer do - {lang, lexer, opts} -> - render_code(lang, lexer, opts, body) - - nil -> - ~s(#{body}) - end - - {:keep, ~s(
#{code}
)} - - {"code", attrs, [body]} when is_binary(body) -> - lexer = - find_value_class(attrs, fn class -> - case Makeup.Registry.fetch_lexer_by_name(class) do - {:ok, {lexer, opts}} -> {class, lexer, opts} - :error -> nil - end - end) - - code = - case lexer do - {lang, lexer, opts} -> - render_code(lang, lexer, opts, body) - - nil -> - ~s(#{body}) - end - - {:keep, code} - - other -> - other - end) - end - - defp rewrite_href_attr(attrs, current_library, libraries) do - Enum.map(attrs, fn - {"href", value} -> - {"href", rewrite_href(value, current_library, libraries)} - - other -> - other - end) - end - - @doc false - def rewrite_href(value, current_library, libraries) do - uri = URI.parse(value) - - case {uri, Path.split(String.trim_leading(uri.path || "", "/"))} do - {%{host: "hexdocs.pm"}, _} -> - value - - {%{host: nil}, ["documentation", _type, guide]} -> - github_guide_link(value, libraries, nil, current_library, guide) - - {%{host: nil}, ["documentation", _type, _subtype, guide]} -> - github_guide_link(value, libraries, nil, current_library, guide) - - {%{host: nil}, [guide]} -> - github_guide_link(value, libraries, nil, current_library, guide) - - _ -> - value - end end - - defp github_guide_link(value, _libraries, _owner, nil, _guide) do - value - end - - defp github_guide_link(value, libraries, owner, library, guide) do - guide = String.trim_trailing(guide, ".md") - - if owner do - if Enum.any?(libraries, &(&1.name == library && &1.repo_org == owner)) do - url(~p"/docs/guides/#{library}/latest/#{guide}") - else - value - end - else - if Enum.any?(libraries, &(&1.name == library)) do - url(~p"/docs/guides/#{library}/latest/#{guide}") - else - value - end - end - end - - defp find_value_class(attrs, func) do - Enum.find_value(attrs, fn - {"class", classes} -> - classes - |> String.split(" ") - |> Enum.find_value(func) - - _ -> - nil - end) - end - - @doc false - def library_for(module, libraries) do - libraries - |> Enum.map(fn library -> - {library, - Enum.find(library.module_prefixes, fn prefix -> - prefix == module || String.starts_with?(module, prefix <> ".") - end)} - end) - |> Enum.filter(fn - {_library, nil} -> - false - - _ -> - true - end) - |> Enum.sort_by(fn {_library, match} -> - -String.length(match) - end) - |> Enum.at(0) - |> case do - {library, _match} -> - library - - _ -> - nil - end - end - - defp render_code(lang, lexer, lexer_opts, code) do - highlighted = - code - |> unescape_html() - |> IO.iodata_to_binary() - |> Makeup.highlight_inner_html( - lexer: lexer, - lexer_options: lexer_opts, - formatter_options: [highlight_tag: "span"] - ) - - ~s(#{highlighted}) - rescue - _ -> - ~s(#{code}) - end - - entities = [{"&", ?&}, {"<", ?<}, {">", ?>}, {""", ?"}, {"'", ?'}] - - for {encoded, decoded} <- entities do - defp unescape_html(unquote(encoded) <> rest), do: [unquote(decoded) | unescape_html(rest)] - end - - defp unescape_html(<>), do: [c | unescape_html(rest)] - defp unescape_html(<<>>), do: [] end diff --git a/lib/ash_hq_web/controllers/home_controller.ex b/lib/ash_hq_web/controllers/home_controller.ex index b5740ae..8dad4cd 100644 --- a/lib/ash_hq_web/controllers/home_controller.ex +++ b/lib/ash_hq_web/controllers/home_controller.ex @@ -3,6 +3,20 @@ defmodule AshHqWeb.HomeController do @url_base if Mix.env() == :dev, do: "localhost:4000/new/", else: "https://new.ash-hq.org/" + def community(conn, _) do + contributors = AshHq.Github.Contributor.in_order!() + + conn + |> assign(:contributor_count, Enum.count(contributors)) + |> assign(:contributors, contributors) + |> render("community.html") + end + + def media(conn, _) do + conn + |> render("media.html") + end + def home(conn, _) do app_name = app_name() diff --git a/lib/ash_hq_web/pages/community.ex b/lib/ash_hq_web/pages/community.ex index 14fc70d..515b285 100644 --- a/lib/ash_hq_web/pages/community.ex +++ b/lib/ash_hq_web/pages/community.ex @@ -10,14 +10,6 @@ defmodule AshHqWeb.Pages.Community do
- - - - -
diff --git a/lib/ash_hq_web/router.ex b/lib/ash_hq_web/router.ex index d7ff759..9d33b93 100644 --- a/lib/ash_hq_web/router.ex +++ b/lib/ash_hq_web/router.ex @@ -25,26 +25,29 @@ defmodule AshHqWeb.Router do get("/:name", AshHqWeb.NewController, :new) end - scope "/new" do - get("/:name", AshHqWeb.NewController, :new) + if Mix.env() == :dev do + scope "/new" do + get("/:name", AshHqWeb.NewController, :new) + end end scope "/", AshHqWeb do pipe_through(:browser) get "/", HomeController, :home + get "/community", HomeController, :community + get "/media", HomeController, :media - live("/media", AppViewLive, :media) live("/blog", AppViewLive, :blog) live("/blog/:slug", AppViewLive, :blog) - live("/community", AppViewLive, :community) - live("/docs/", AppViewLive, :docs_dsl) - live("/docs/guides/:library/:version/*guide", AppViewLive, :docs_dsl) - live("/docs/dsl/:dsl_target", AppViewLive, :docs_dsl) - live("/docs/dsl/:library/:version", AppViewLive, :docs_dsl) - live("/docs/dsl/:library/:version/:extension", AppViewLive, :docs_dsl) - live("/docs/module/:library/:version/:module", AppViewLive, :docs_dsl) - live("/docs/mix_task/:library/:version/:mix_task", AppViewLive, :docs_dsl) - live("/docs/:library/:version", AppViewLive, :docs_dsl) + # live("/community", AppViewLive, :community) + # live("/docs/", AppViewLive, :docs_dsl) + # live("/docs/guides/:library/:version/*guide", AppViewLive, :docs_dsl) + # live("/docs/dsl/:dsl_target", AppViewLive, :docs_dsl) + # live("/docs/dsl/:library/:version", AppViewLive, :docs_dsl) + # live("/docs/dsl/:library/:version/:extension", AppViewLive, :docs_dsl) + # live("/docs/module/:library/:version/:module", AppViewLive, :docs_dsl) + # live("/docs/mix_task/:library/:version/:mix_task", AppViewLive, :docs_dsl) + # live("/docs/:library/:version", AppViewLive, :docs_dsl) # for showing deprecated forum content live("/forum", AppViewLive, :forum) diff --git a/lib/ash_hq_web/templates/home/community.html.heex b/lib/ash_hq_web/templates/home/community.html.heex new file mode 100644 index 0000000..418427c --- /dev/null +++ b/lib/ash_hq_web/templates/home/community.html.heex @@ -0,0 +1,197 @@ + +
+
+
+ +
+
+ +
+
+
+
+
+ + + + + +
+ +
+
+ The Ash Community +
+
+ A thriving group of + friendly folks + ready to welcome developers at + all skill levels. + All questions, ideas and contributions are valuable, so + join in! +
+
+
+
+ + + + + + + + + + +
+ + Discord + + + + +
+ The Ash discord is where you'll find people sharing ideas, collaborating on code, and discussing the Elixir ecosystem. +
+
+ +
+
+ + + +
+ + ElixirForum + + + + + + +
+ The Ash section on Elixir Forum is the perfect place to ask questions or see what other people have been building. +
+
+ +
+
+ + + + + + + + + +
+ + GitHub + + + + +
+ The Ash Project on GitHub is your one stop shop for all of the source code across the various Ash libraries. +
+
+
+ +
+ + Become a contributor + +

+ Join {@contributor_count} contributors and counting! +

+ +
+ <%= for %{login: login, avatar_url: avatar_url, html_url: html_url} <- @contributors do %> + + {login} + + <% end %> +
+
+ +
+
+
+
diff --git a/lib/ash_hq_web/templates/home/home.html.heex b/lib/ash_hq_web/templates/home/home.html.heex index 2d46a7e..b95d72f 100644 --- a/lib/ash_hq_web/templates/home/home.html.heex +++ b/lib/ash_hq_web/templates/home/home.html.heex @@ -1,43 +1,3 @@ - - - -
@@ -89,11 +49,14 @@
@@ -270,64 +244,21 @@
- -
-
-
- -
-
-
-
-
- - - -
-

Resources

-

- Plug and play building blocks that scale with the complexity of your domain. -

-
-
- - -
-
-
-
-
- - - - - - - -
-

GraphQL

-

- Easily create rich, customizable, full featured GraphQL APIs. -

-
-
- - -
-
-
-
-
- - - -
-

JSON:API

-

- Create JSON:API spec compliant apis in minutes, not months. -

-
-
-
-
-
+<%!--
+<%!-- id="logos" --%> +<%!-- class="max-w-5xl mx-auto text-center lg:px-8 backdrop-blur-lg bg-slate-950/50 rounded-2xl border border-primary-light-500/30 p-4" --%> +<%!-- > --%> +<%!--

Trusted in production!

--%> +<%!--
--%> +<%!-- Company 1 --%> +<%!-- Company 2 --%> +<%!-- Company 3 --%> +<%!-- Company 4 --%> +<%!-- Company 5 --%> +<%!-- Company 6 --%> +<%!-- Company 7 --%> +<%!-- Company 8 --%> +<%!-- Company 9 --%> +<%!-- Company 10 --%> +<%!--
--%> +<%!--
--%> diff --git a/lib/ash_hq_web/templates/home/media.html.heex b/lib/ash_hq_web/templates/home/media.html.heex new file mode 100644 index 0000000..24a4ca0 --- /dev/null +++ b/lib/ash_hq_web/templates/home/media.html.heex @@ -0,0 +1,70 @@ +
+
+
+ +
+
+ +
+
+
+
+
+
Podcasts
+