This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as d3 from "d3"; | |
| function extentTime(ref) { | |
| let to = ref || new Date(); | |
| let totalMilliSeconds = to.getTime(); | |
| let millisecondsToSubtract = 60 * 1000; | |
| let from = new Date(totalMilliSeconds - millisecondsToSubtract); | |
| return d3.extent([from, to]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule PolarisWeb.Generator do | |
| @moduledoc false | |
| use Phoenix.ConnTest | |
| @endpoint PolarisWeb.Endpoint | |
| def generate() do | |
| conn = Phoenix.ConnTest.build_conn() | |
| base = Application.get_env(:polaris, :generator)[:out] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| text: """ | |
| |## Phoenix Web-Framework ## | |
| | | |
| |I'll show you how we create a boilerplate code that has all the necessary functions to get you started quickly. | |
| |This code is then ready for further adjustments and changes. First we create a Phoenix project without | |
| |database connection: | |
| | | |
| |```elixir | |
| |#> mix phx.new polaris --no-ecto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="row"> | |
| <article class="column"> | |
| <%= @paragraph["text"] |> strip_margin() |> markdown() |> raw() %> | |
| </article> | |
| </div> | |
| <%= if length(@paragraph["images"]) > 0 do %> | |
| <div class="row"> | |
| <%= for img <- @paragraph["images"] do %> | |
| <div class="column"> | |
| <figure> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section> | |
| <div class="row"> | |
| <div class="column"> | |
| <h1><%= @page_title%></h1> | |
| </div> | |
| </div> | |
| <%= render_many @pars, PolarisWeb.PageView, "paragraph.html", as: :paragraph, conn: @conn %> | |
| </section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule PolarisWeb.PageView do | |
| use PolarisWeb, :view | |
| def markdown(string) do | |
| with {:ok, html_doc, []} <- Earmark.as_html(strip_margin(string)) do | |
| html_doc | |
| end | |
| end | |
| def strip_margin(string) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule PolarisWeb.PageController do | |
| use PolarisWeb, :controller | |
| alias Polaris.Page | |
| def index(conn, _params) do | |
| %Page{title: title, content: content} = Polaris.Site.index() | |
| conn | |
| |> assign(:page_title, title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Polaris.Site do | |
| @moduledoc false | |
| alias Polaris.Page | |
| pages_paths = "hocon/**/*.conf" |> Path.wildcard() |> Enum.sort() | |
| pages = for page_path <- pages_paths do | |
| @external_resource Path.relative_to_cwd(page_path) | |
| Page.parse!(page_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Polaris.Page do | |
| @moduledoc false | |
| alias Polaris.Page | |
| @enforce_keys [:filename, :title, :content] | |
| defstruct [:filename, :section, :title, :content] | |
| def parse!(filename) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| iex(9)> Hocon.decode(File.read!("./hocon/index.conf")) | |
| {:ok, | |
| %{ | |
| "pars" => [ | |
| %{ | |
| "text" => "|## Introduction ##\n |\n |Phoenix is not only an excellent web framework, but also it can be transformed with a few steps into a\n |static content generator. You need some programming knowledge, so this way is\n |rather something for developers.\n |\n |Usually a static content generator is a system that reads a text document with a few\n |meta-information such as author, date, title and a markdown block to produce\n |HTML files, which can be uploaded to a web server.\n |\n |There are a lot of existing solutions for this, so why would you create a new system\n |develop? Let's take a look at the current limits. Maybe we can find this something\n |to the back.\n |\n |### text documents ###\n |Usually, the structure of a document is rigid and sim |
NewerOlder