Current section

37 Versions

Jump to

Compare versions

30 files changed
+1079 additions
-965 deletions
  @@ -17,7 +17,7 @@ _If you are having problems, view `README_INSTALL.md` for manual instructions._
17 17
18 18 ```elixir
19 19 def deps do
20 - [{:thesis, "~> 0.0.12"}]
20 + [{:thesis, "~> 0.0.13"}]
21 21 end
22 22
23 23 def application do
  @@ -88,6 +88,25 @@ becomes...
88 88 <h1><%= content(@conn, "Title identifier", :text, do: "My Title") %></h1>
89 89 ```
90 90
91 + ### Meta Title and Description
92 +
93 + In your layout, you can output the current title and description like so:
94 +
95 + ```eex
96 + <title><%= page_title(@conn, "Default Title") %></title>
97 + <meta name="description" content="<%= page_description(@conn, "Default Description") %>" />
98 + ```
99 +
100 + Some prefer to set the page title and description in their controller actions:
101 +
102 + ```eex
103 + def about(conn, params) do
104 + @title = Thesis.View.page_title(conn, "About My Company")
105 + @description = Thesis.View.page_description(conn, "A relevant description here.")
106 + end
107 +
108 + ```
109 +
91 110 ## Authorization
92 111
93 112 You probably don't want your website editable by the world. Thesis doesn't
  @@ -14,10 +14,11 @@
14 14 <<"priv/templates/thesis.install/migration.exs">>,
15 15 <<"priv/templates/thesis.install/thesis_auth.exs">>,
16 16 <<"web/static/css/_extends/_extends.sass">>,
17 - <<"web/static/css/_extends/_forms.scss">>,
17 + <<"web/static/css/_extends/_forms.sass">>,
18 18 <<"web/static/css/_mixins/_barber-pole.sass">>,
19 19 <<"web/static/css/_mixins/_editor.sass">>,
20 20 <<"web/static/css/_mixins/_mixins.sass">>,
21 + <<"web/static/css/_mixins/_normalize.scss">>,
21 22 <<"web/static/css/_vendor/_medium-editor.scss">>,
22 23 <<"web/static/css/_vendor/bourbon/_bourbon-deprecated-upcoming.scss">>,
23 24 <<"web/static/css/_vendor/bourbon/_bourbon.scss">>,
  @@ -105,21 +106,21 @@
105 106 <<"web/static/css/components/_content.sass">>,
106 107 <<"web/static/css/components/_editor.sass">>,
107 108 <<"web/static/css/components/_fader.sass">>,
108 - <<"web/static/css/components/_modal.sass">>,
109 - <<"web/static/css/thesis.sass">>,
109 + <<"web/static/css/components/_tray.sass">>,<<"web/static/css/thesis.sass">>,
110 110 <<"web/static/js/components/add_button.js">>,
111 + <<"web/static/js/components/attribution_text.js">>,
111 112 <<"web/static/js/components/cancel_button.js">>,
112 113 <<"web/static/js/components/delete_button.js">>,
113 114 <<"web/static/js/components/edit_button.js">>,
114 115 <<"web/static/js/components/save_button.js">>,
115 116 <<"web/static/js/components/settings_button.js">>,
116 - <<"web/static/js/components/style_button.js">>,
117 + <<"web/static/js/components/settings_tray.js">>,
117 118 <<"web/static/js/thesis-editor.js">>,<<"web/static/js/utilities/net.js">>,
118 119 <<"mix.exs">>,<<"README.md">>,<<"README_INSTALL.md">>,<<"LICENSE.md">>,
119 120 <<"package.json">>]}.
120 121 {<<"licenses">>,[<<"MIT">>]}.
121 122 {<<"links">>,
122 - [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.12/api-reference.html">>},
123 + [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.13/api-reference.html">>},
123 124 {<<"GitHub">>,<<"https://github.com/infinite_red/thesis">>}]}.
124 125 {<<"maintainers">>,
125 126 [<<"Jamon Holmgren">>,<<"Ken Miller">>,<<"Daniel Berkompas">>]}.
  @@ -145,4 +146,4 @@
145 146 [{<<"app">>,<<"plug">>},
146 147 {<<"optional">>,false},
147 148 {<<"requirement">>,<<"~> 1.0">>}]}]}.
148 - {<<"version">>,<<"0.0.12">>}.
149 + {<<"version">>,<<"0.0.13">>}.
  @@ -44,4 +44,5 @@ defmodule Thesis.Controller.Plug do
44 44 |> assign(:thesis_page, current_page)
45 45 |> assign(:thesis_content, page_contents)
46 46 end
47 +
47 48 end
  @@ -77,9 +77,9 @@ defmodule Thesis.View do
77 77 Doctests:
78 78
79 79 iex> {:safe, editor} = Thesis.View.thesis_editor(%Plug.Conn{assigns: %{editable: true}})
80 - iex> String.contains?(editor, "<style>")
80 + iex> String.contains?(editor, "/thesis/thesis.css")
81 81 true
82 - iex> String.contains?(editor, "thesis-editor-container")
82 + iex> String.contains?(editor, "thesis-container")
83 83 true
84 84 iex> String.contains?(editor, "<script>")
85 85 true
  @@ -90,13 +90,51 @@ defmodule Thesis.View do
90 90 @spec thesis_editor(Plug.Conn.t) :: {:safe, String.t}
91 91 def thesis_editor(conn) do
92 92 if editable?(conn) do
93 - editor = content_tag(:div, "", id: "thesis-editor-container")
93 + editor = content_tag(:div, "", id: "thesis-container")
94 94 safe_concat([thesis_style, editor, thesis_js])
95 95 else
96 96 raw ""
97 97 end
98 98 end
99 99
100 + @doc """
101 + Outputs the page title or a provided default.
102 +
103 + Doctests:
104 +
105 + iex> page = %Thesis.Page{title: "Test Title"}
106 + iex> conn = %Plug.Conn{assigns: %{thesis_page: page}}
107 + iex> Thesis.View.page_title(conn, "Default Title")
108 + "Test Title"
109 + iex> page = %Thesis.Page{}
110 + iex> conn = %Plug.Conn{assigns: %{thesis_page: page}}
111 + iex> Thesis.View.page_title(conn, "Default Title")
112 + "Default Title"
113 + """
114 + def page_title(%Plug.Conn{assigns: %{thesis_page: page}}, default) do
115 + page.title || default
116 + end
117 + def page_title(_conn, default), do: default
118 +
119 + @doc """
120 + Outputs the page title or a provided default.
121 +
122 + Doctests:
123 +
124 + iex> page = %Thesis.Page{description: "Test Description"}
125 + iex> conn = %Plug.Conn{assigns: %{thesis_page: page}}
126 + iex> Thesis.View.page_description(conn, "Default Description")
127 + "Test Description"
128 + iex> page = %Thesis.Page{}
129 + iex> conn = %Plug.Conn{assigns: %{thesis_page: page}}
130 + iex> Thesis.View.page_description(conn, "Default Description")
131 + "Default Description"
132 + """
133 + def page_description(%Plug.Conn{assigns: %{thesis_page: page}}, default) do
134 + page.description || default
135 + end
136 + def page_description(_conn, default), do: default
137 +
100 138 defp make_page(request_path) do
101 139 %Thesis.Page{slug: request_path}
102 140 end
  @@ -128,7 +166,7 @@ defmodule Thesis.View do
128 166 }
129 167
130 168 document.addEventListener('DOMContentLoaded', function (event) {
131 - if (document.querySelector('#thesis-editor-container')) {
169 + if (document.querySelector('#thesis-container')) {
132 170 loadThesis()
133 171 }
134 172 })
  @@ -1,6 +1,6 @@
1 1 defmodule Thesis.Mixfile do
2 2 use Mix.Project
3 - @version "0.0.12" # REMEMBER TO UPDATE package.json and README.md
3 + @version "0.0.13" # REMEMBER TO UPDATE package.json and README.md
4 4
5 5 def project do
6 6 [
Loading more files…