defmodule SukaatoWeb.PageHTML do @moduledoc """ This module contains pages rendered by PageController. See the `page_html` directory for all templates available. """ alias SukaatoWeb.Marker alias SukaatoWeb.Theme use SukaatoWeb, :html embed_templates "page_html/*" @rel_proj_root "../../.." @site_config_file Path.expand(@rel_proj_root <> "/site.toml", __DIR__) @site_config elem(Toml.decode_file(@site_config_file), 1) attr :audience, :string, default: "humans" attr :home, :string, default: "but one recessed sulci of the global encephalon" attr :site_name, :string, default: @site_config["site"]["name"] attr :site_author, :string, default: @site_config["site"]["author"] attr :site_desc, :string, default: @site_config["site"]["desc"] attr :badge_collection, :list, default: [] attr :page_links, :list, default: [ %PageLink{name: "Home", uri: "/"}, %PageLink{name: "GPG", uri: "/pubkey"}, %PageLink{name: "Contact", uri: "/contact"} ] attr :page_query, :string, default: "" attr :thinkers, :list, default: [ %Thinker{name: "Plato", uri: "https://3.bp.blogspot.com/-4tLynuYBkhQ/TqcL1B3lDVI/AAAAAAAAAB0/DqucJFRCgxo/s1600/Plato.jpg", type: ["Philosopher", "Social Theorist", "Political Theorist"], desc: "An important philosopher", concepts: ["theory of forms", "divisions of the soul"]} ] attr :icon, :string, default: "default" attr :btn_name, :map, default: %{ names: [ "Log In", "Log Out", "Register" ], choice: 0 } def greet(assigns) do ~H"""

Welcome, <%= @audience %>, to <%= @home %>!

""" end def html_head(assigns) do ~H""" <% # %> <%= @site_name %> """ end def navify(assigns) do ~H""" <%= if @page_links != nil do %> <%= if length(@page_links) > 0 do %> <%= for anchor <- @page_links do %> <%= anchor.name %> <% end %> <% else %> Home <% end %> <% end %> """ end def submission(assigns) do ~H""" <% button_name = Enum.at(@btn_name.names, @btn_name.choice) %> """ end def markdown_content(assigns) do ~H""" <% result = Marker.render_mark(@page_query) %> <% content = if elem(result, 0) == :ok, do: elem(result, 1) %> <%= raw content %> """ end def thinkify(assigns) do ~H""" <%= if @thinkers != nil do %> <%= if length(@thinkers) > 0 do %> <%= for thinker <- @thinkers do %> <% underscored_name = String.split(thinker.name, " ") %> <% underscored_name = Enum.join(underscored_name, "_") %>

<%= thinker.name %>

<%= if Map.has_key?(thinker, :uri) do %>
<% end %>
<%= if Map.has_key?(thinker, :type) do %> <% thinker_types = Enum.map(thinker.type, fn tt -> "" <> tt <> "" end) %> <% thinker_type = Enum.join(thinker_types, ", ") %> <%= raw thinker_type %>
<% end %> <%= if Map.has_key?(thinker, :concepts) do %> <% thinker_concepts = Enum.map(thinker.concepts, fn tc -> "" <> tc <> "" end) %> <% thinker_concepts = Enum.join(thinker_concepts, ", ") %> concepts:
<%= raw thinker_concepts %>

<% end %> <%= if Map.has_key?(thinker, :desc) do %> <%= thinker.desc %>
<% end %>
<% end %> <% end %> <% end %> """ end def affiliate(assigns) do ~H""" <% current_theme = Theme.list(:current) %> <% rel_proj_root = "../../.." %> <%= raw File.read!(Path.expand(rel_proj_root <> "/priv/static/images/themes/" <> current_theme <> "/icons/" <> @icon <> ".svg", __DIR__)) %> """ end def html_foot(assigns) do # @TODO do HEEx loop on @badge_collection ~H""" """ end end