Explorar el Código

Remove most of the code to prepare merge with nodejs code

theenglishway (time) hace 2 años
padre
commit
15dba05316

+ 0 - 21
README.md

@@ -1,21 +0,0 @@
-# CvGen
-
-**TODO: Add description**
-
-## Installation
-
-If [available in Hex](https://hex.pm/docs/publish), the package can be installed
-by adding `cv_gen` to your list of dependencies in `mix.exs`:
-
-```elixir
-def deps do
-  [
-    {:cv_gen, "~> 0.1.0"}
-  ]
-end
-```
-
-Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
-and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
-be found at <https://hexdocs.pm/cv_gen>.
-

+ 0 - 11
lib/application.ex

@@ -1,11 +0,0 @@
-defmodule CvGen.Application do
-  use Application
-
-  @impl true
-  def start(_type, _args) do
-    children = [{CvGen.Watchdog, []}]
-
-    opts = [strategy: :one_for_one, name: ExAccounts.Supervisor]
-    Supervisor.start_link(children, opts)
-  end
-end

+ 0 - 23
lib/cv_gen.ex

@@ -1,23 +0,0 @@
-defmodule CvGen do
-  @moduledoc """
-  Documentation for `CvGen`.
-  """
-  @template_file "lib/templates/cv.html.heex"
-  @data_file "priv/data/cv.json"
-  @output_file "priv/output/cv.html"
-
-  def generate do
-    with raw_data <- File.read!(@data_file),
-         {:ok, assigns} <-
-           Jason.decode(raw_data, keys: &(&1 |> Macro.underscore() |> String.to_atom())),
-         res <- CvGenView.cv(assigns) |> Phoenix.HTML.Safe.to_iodata() |> List.to_string(),
-         do: File.write!(@output_file, res)
-  end
-
-  def paths(),
-    do: %{
-      template: @template_file,
-      data: @data_file,
-      output: @output_file
-    }
-end

+ 0 - 13
lib/cv_gen_view.ex

@@ -1,13 +0,0 @@
-defmodule CvGenView do
-  use Phoenix.Component
-  alias CvGenView.{Layout, Basics, Work, Skill, Education, Language}
-  @after_compile __MODULE__
-
-  embed_templates("templates/*")
-
-  def __after_compile__(_env, _bytecode) do
-    CvGen.generate()
-  end
-
-  def as_css(raw) when is_binary(raw), do: Phoenix.HTML.raw(raw)
-end

+ 0 - 9
lib/regenerate_on_compilation.ex

@@ -1,9 +0,0 @@
-defmodule CvGen.RegenerateOnCompilation do
-  defmacro __using__([]) do
-    quote do
-      @after_compile __MODULE__
-
-      def __after_compile__(_env, _bytecode), do: CvGen.generate()
-    end
-  end
-end

+ 0 - 108
lib/templates/cv.html.heex

@@ -1,108 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>CV Julien HERVÉ</title>
-    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans" />
-    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300" />
-    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@700" />
-
-    <link
-      rel="stylesheet"
-      href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
-      integrity="sha512NhSC1YmyruXifcj/KFRWoC561YpHpc5Jtzgvbuzx5VozKpWvQ+4nXhPdFgmx8xqexRcpAglTj9sIBWINXa8x5w=="
-      crossorigin="anonymous"
-      referrerpolicy="no-referrer"
-    />
-    <style>
-      <%= Layout.resets() |> as_css() %>
-      <%= Layout.page_css() |> as_css() %>
-      <%= Layout.page_print_css() |> as_css() %>
-
-      dl {
-        display: grid;
-        grid-template-columns: auto 1fr;
-        align-items: center;
-      }
-
-      dt {
-        grid-column: 1/2;
-      }
-
-      dd {
-        grid-column: 2/3;
-      }
-
-      <%= Work.css() |> as_css() %>
-      <%= Basics.css() |> as_css() %>
-      <%= Skill.css() |> as_css() %>
-      <%= Education.css() |> as_css() %>
-      <%= Language.css() |> as_css() %>
-    </style>
-  </head>
-
-  <body>
-    <div id="basics">
-      <Basics.basics name={@basics.name} title={@basics.label} />
-    </div>
-
-    <div id="about" class="section">
-      <h1>En résumé</h1>
-      <Basics.about summary={@basics.summary} />
-    </div>
-
-    <div id="contact" class="section">
-      <h1>Contact</h1>
-
-      <Basics.contact
-        email={@basics.email}
-        phone={@basics.phone}
-        location={@basics.location}
-        profiles={@basics.profiles}
-      />
-    </div>
-
-    <div id="work" class="section">
-      <h1>Expériences professionnelles</h1>
-      <ol>
-        <%= for work <- @work do %>
-          <li>
-            <Work.work {work} />
-          </li>
-        <% end %>
-      </ol>
-    </div>
-
-    <div id="skills" class="section">
-      <h1>Compétences</h1>
-
-      <ul>
-        <%= for skill <- @skills do %>
-          <li><Skill.skill skill={skill} /></li>
-        <% end %>
-      </ul>
-    </div>
-
-    <div id="education" class="section">
-      <h1>Formation</h1>
-
-      <ol>
-        <%= for educ <- @education do %>
-          <li><Education.education {educ} /></li>
-        <% end %>
-      </ol>
-    </div>
-
-    <div id="languages" class="section">
-      <h1>Langues</h1>
-
-      <ul>
-        <%= for lang <- @languages do %>
-          <li><Language.language lang={lang} /></li>
-        <% end %>
-      </ul>
-    </div>
-  </body>
-</html>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 134
lib/views/basics.ex


+ 0 - 55
lib/views/date.ex

@@ -1,55 +0,0 @@
-defmodule CvGenView.Date do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-
-  attr(:start_date, :string, required: true)
-  attr(:end_date, :string, default: nil)
-
-  def time_span(assigns) when assigns.start_date == assigns.end_date,
-    do: ~H"""
-    <div class="period">
-      <.date date={@start_date} />
-    </div>
-    """
-
-  def time_span(assigns),
-    do: ~H"""
-    <div class="period">
-      <.date date={@start_date} /> - <.date date={@end_date} />
-    </div>
-    """
-
-  attr(:date, :any)
-  attr(:rest, :global)
-
-  def date(assigns) do
-    ~H"""
-    <time datetime={@date} {@rest}><%= localized(@date) %></time>
-    """
-  end
-
-  defp localized(nil), do: "Aujourd'hui"
-
-  defp localized(date) when is_binary(date) do
-    case String.split(date, "-") do
-      [year, month] ->
-        {year, month} = {String.to_integer(year), String.to_integer(month)}
-        Date.new!(year, month, 1) |> localized()
-
-      [year] ->
-        year
-    end
-  end
-
-  defp localized(date) when is_struct(date, Date),
-    do:
-      Calendar.strftime(
-        date,
-        "%B %Y",
-        month_names: fn month ->
-          {"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre",
-           "Octobre", "Novembre", "Décembre"}
-          |> elem(month - 1)
-        end
-      )
-end

+ 0 - 59
lib/views/education.ex

@@ -1,59 +0,0 @@
-defmodule CvGenView.Education do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-  alias CvGenView.{Text, Date}
-
-  attr(:institution, :string, required: true)
-  attr(:location, :string, required: true)
-  attr(:start_date, :string, required: true)
-  attr(:end_date, :string, required: true)
-  attr(:summary, :string, required: true)
-
-  def education(assigns) do
-    ~H"""
-    <div class="education">
-      <Date.time_span start_date={@start_date} end_date={@end_date} />
-      <div class="box">
-        <h1><%= @institution %></h1>
-        <h2><%= @area %></h2>
-        <Text.text text={@summary} />
-      </div>
-    </div>
-    """
-  end
-
-  # TODO: Almost the same as in Work heading, but not quite.
-  def css(),
-    do: """
-    .education h1,
-    .education h2,
-    .education p {
-      margin: 0;
-    }
-
-    .education .box {
-      display: flex;
-      flex-direction: column;
-      gap: 0.5em;
-
-      background-color: #eee;
-      padding: 0.5em;
-
-      margin-bottom: 1em;
-    }
-
-    .education .box > h1 {
-      font-weight: bold;
-    }
-
-    .education .box > h2 {
-      font-weight: normal;
-      padding-left: 0.5em;
-    }
-
-    .education .box > p {
-      font-weight: lighter;
-      padding-left: 0.5em;
-    }
-    """
-end

+ 0 - 27
lib/views/language.ex

@@ -1,27 +0,0 @@
-defmodule CvGenView.Language do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-
-  attr(:lang, :map)
-
-  def language(assigns) do
-    ~H"""
-    <div class="language"><span><%= @lang.language %></span><span><%= @lang.fluency %></span></div>
-    """
-  end
-
-  def css(),
-    do: """
-      #languages > ul > li {
-        border: #bbb solid 1px;
-        margin-top: 0.3em;
-        padding: 0.4em;
-        font-weight: lighter;
-      }
-
-      .language {
-        display: flex;
-        justify-content: space-between;
-      }
-    """
-end

+ 0 - 144
lib/views/layout.ex

@@ -1,144 +0,0 @@
-defmodule CvGenView.Layout do
-  use CvGen.RegenerateOnCompilation
-
-  def resets(),
-    do: """
-    @charset "utf-8";
-
-    @-webkit-viewport {
-      width: device-width;
-    }
-
-    @-moz-viewport {
-      width: device-width;
-    }
-
-    @-ms-viewport {
-      width: device-width;
-    }
-
-    @-o-viewport {
-      width: device-width;
-    }
-
-    @viewport {
-      width: device-width;
-    }
-
-    * {
-      box-sizing: border-box;
-    }
-
-    h1, h2, h3, h4, h5, h6 {
-      font-size: 1em;
-    }
-
-    ol,
-    ul {
-      list-style: none;
-      padding-inline: 0;
-    }
-
-    dd {
-      margin: 0;
-    }
-    """
-
-  def page_css(),
-    do: """
-    html {
-      background-color: rgb(51, 73, 96);
-    }
-
-    body {
-      width: 90%;
-      max-width: 120ch;
-      margin-top: 2em;
-      margin-bottom: 2em;
-      margin-right: auto;
-      margin-left: auto;
-      padding: 1em;
-      background-color: white;
-      font-family: 'Open Sans', Arial, Tahoma;
-      font-weight: 400;
-
-      display: grid;
-      grid-template-areas:
-      "basics basics"
-      "about contact"
-      "work skills"
-      "work education"
-      "work languages"
-      "work _";
-      grid-template-columns: 2fr 1fr;
-      column-gap: 1em;
-      row-gap: 0.5em;
-    }
-
-    #basics {
-      grid-area: basics;
-      border-bottom: lightgray solid 0.1em;
-    }
-    #about {
-      grid-area: about;
-    }
-    #work {
-      grid-area: work;
-    }
-    #education {
-      grid-area: education;
-    }
-    #skills {
-      grid-area: skills;
-    }
-    #languages {
-      grid-area: languages;
-    }
-
-    .section > h1 {
-      color: #227c74;
-      text-transform: uppercase;
-      font-size: larger;
-    }
-
-    a {
-      color: #337ab7;
-    }
-
-    a:focus, a:hover {
-      color: #23527c;
-    }
-    """
-
-  def page_print_css(),
-    do: """
-      @media print {
-        html {
-          background-color: initial;
-        }
-
-        body {
-          width: 100%;
-          grid-template-areas:
-          "basics basics"
-          "about contact"
-          "education skills"
-          "education languages"
-          "work work";
-          grid-template-columns: 2fr 1fr;
-          margin-top: 0;
-          margin-bottom: 0;
-          padding: 0;
-          font-size: 14.7px;
-        }
-
-        #education {
-          align-self: center;
-        }
-
-        .work {
-          break-inside: avoid;
-        }
-      }
-    """
-end

+ 0 - 44
lib/views/skill.ex

@@ -1,44 +0,0 @@
-defmodule CvGenView.Skill do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-
-  attr(:skill, :map)
-
-  def skill(assigns) do
-    ~H"""
-    <h1><%= @skill.name %></h1>
-    <ul class="keywords">
-      <%= for kw <- @skill.keywords do %>
-        <li><%= kw %></li>
-      <% end %>
-    </ul>
-    """
-  end
-
-  def css(),
-    do: """
-    #skills ul.keywords {
-      display: flex;
-      flex-wrap: wrap;
-      gap: 0.2em;
-    }
-
-    #skills .keywords > li {
-      padding: 0.3em 0.6em;
-      font-size: 0.7em;
-      font-weight: 700;
-      color: #fff;
-      text-align: center;
-      background-color: #333;
-      border-radius: 0.5em;
-    }
-
-    @media print {
-      #skills .keywords > li {
-        color: #000;
-        background-color: #fff;
-        border: #000 solid 0.2em;
-      }
-    }
-    """
-end

+ 0 - 19
lib/views/text.ex

@@ -1,19 +0,0 @@
-defmodule CvGenView.Text do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-
-  attr(:text, :any, required: true)
-  attr(:rest, :global)
-
-  def text(assigns) when is_binary(assigns.text),
-    do: ~H"""
-    <p {@rest}><%= @text %></p>
-    """
-
-  def text(assigns) when is_list(assigns.text),
-    do: ~H"""
-    <%= for paragraph <- @text do %>
-      <p {@rest}><%= paragraph %></p>
-    <% end %>
-    """
-end

+ 0 - 133
lib/views/work.ex

@@ -1,133 +0,0 @@
-defmodule CvGenView.Work do
-  use Phoenix.Component
-  use CvGen.RegenerateOnCompilation
-  alias CvGenView.{Date, Text}
-
-  attr(:name, :string, required: true)
-  attr(:start_date, :any, required: true)
-  attr(:end_date, :any, default: nil)
-  attr(:summary, :string, required: true)
-  attr(:location, :string, required: true)
-  attr(:highlights, :list, required: true)
-  attr(:skills, :list, default: [])
-
-  def work(assigns) do
-    ~H"""
-    <div class="work">
-      <div class="heading">
-        <h1><%= @name %></h1>
-        <span class="location"><%= @location %></span>
-        <Date.time_span start_date={@start_date} end_date={@end_date} />
-      </div>
-
-      <h1><%= @position %></h1>
-
-      <Text.text text={@summary} class="summary" />
-
-      <h2>Points clés</h2>
-      <ul class="highlights">
-        <%= for highlight <- @highlights do %>
-          <li><%= highlight %></li>
-        <% end %>
-      </ul>
-
-      <ul class="skills">
-        <%= for skill <- @skills do %>
-          <li><%= skill %></li>
-        <% end %>
-      </ul>
-    </div>
-    """
-  end
-
-  def css,
-    do: """
-    .work h1 {
-      margin: 0;
-    }
-
-    .work > * {
-      padding-left: 0.5em;
-    }
-
-    .work > .heading {
-      display: grid;
-      grid-template-areas:
-      "header location"
-      "period _";
-      gap: 0.5em;
-
-      background-color: #eee;
-      padding: 0.5em;
-
-      margin-bottom: 1em;
-    }
-
-    .work > .heading > h1 {
-      font-weight: bold;
-    }
-
-    .work > .heading > .location {
-      font-weight: bold;
-      justify-self: end;
-      text-align: end;
-    }
-
-    .work > .heading > .period {
-      font-weight: lighter;
-    }
-
-    .work > h1 {
-      font-weight: bold;
-    }
-
-    .work > h2 {
-      font-size: 0.85em;
-    }
-
-    .work > p {
-      margin: 0.5em 0;
-    }
-
-    .work ul.highlights > li {
-      border: #bbb solid 1px;
-      margin-top: 0.3em;
-      padding: 0.4em;
-      font-weight: lighter;
-    }
-
-    .work ul.highlights {
-
-    }
-
-    #work > ol > li {
-      margin: 2em auto;
-      padding-left: 0.5em;
-    }
-
-    #work ul.skills {
-      display: flex;
-      flex-wrap: wrap;
-      gap: 0.2em;
-      margin-top: 1em;
-    }
-
-    #work .skills > li {
-      padding: 0.3em 0.6em;
-      font-size: 0.7em;
-      font-weight: 700;
-      color: #fff;
-      text-align: center;
-      background-color: #333;
-      border-radius: 0.5em;
-    }
-
-    @media print {
-      #work .skills > li {
-        color: #000;
-        background-color: #fff;
-        border: #000 solid 0.2em;
-      }
-    }
-    """
-end

+ 0 - 50
lib/watchdog.ex

@@ -1,50 +0,0 @@
-defmodule CvGen.Watchdog do
-  use GenServer
-  require Logger
-
-  @name __MODULE__
-  @paths CvGen.paths()
-
-  def start_link(_), do: GenServer.start(__MODULE__, [], name: @name)
-
-  def force_reload(), do: GenServer.call(@name, :reload, 500)
-
-  @impl true
-  def init(_), do: {:ok, %{tpl_hash: "", json_hash: ""}, {:continue, :trigger_timer}}
-
-  @impl true
-  def handle_info(:timer_expired, state) do
-    state =
-      with tpl_hash <- hash(@paths.template),
-           json_hash <- hash(@paths.data) do
-        if tpl_hash != state.tpl_hash or json_hash != state.json_hash do
-          Logger.info("Content has changed, reloading")
-          CvGen.generate()
-          %{tpl_hash: tpl_hash, json_hash: json_hash}
-        else
-          state
-        end
-      end
-
-    {:noreply, state, {:continue, :trigger_timer}}
-  end
-
-  defp hash(path) do
-    contents = File.read!(path)
-    :crypto.hash(:md5, contents) |> Base.encode16()
-  end
-
-  @impl true
-  def handle_call(:reload, _, _) do
-    CvGen.generate()
-
-    {:reply, :ok, %{tpl_hash: hash(@paths.template), json_hash: hash(@paths.data)},
-     {:continue, :trigger_timer}}
-  end
-
-  @impl true
-  def handle_continue(:trigger_timer, state) do
-    Process.send_after(self(), :timer_expired, 100)
-    {:noreply, state}
-  end
-end

+ 0 - 30
mix.exs

@@ -1,30 +0,0 @@
-defmodule CvGen.MixProject do
-  use Mix.Project
-
-  def project do
-    [
-      app: :cv_gen,
-      version: "0.1.0",
-      elixir: "~> 1.14",
-      start_permanent: Mix.env() == :prod,
-      deps: deps()
-    ]
-  end
-
-  # Run "mix help compile.app" to learn about applications.
-  def application do
-    [
-      mod: {CvGen.Application, []},
-      extra_applications: [:logger, :eex, :crypto]
-    ]
-  end
-
-  # Run "mix help deps" to learn about dependencies.
-  defp deps do
-    [
-      {:jason, "~> 1.4"},
-      {:phoenix_html, "~> 3.3"},
-      {:phoenix_live_view, "~> 0.18.18"}
-    ]
-  end
-end

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 15
mix.lock