Current section

37 Versions

Jump to

Compare versions

21 files changed
+247 additions
-63 deletions
  @@ -30,7 +30,7 @@ _If you are having problems, view `README_INSTALL.md` for manual instructions._
30 30
31 31 ```elixir
32 32 def deps do
33 - [{:thesis, "~> 0.0.19"}]
33 + [{:thesis, "~> 0.0.20"}]
34 34 end
35 35
36 36 def application do
  @@ -146,7 +146,25 @@ becomes...
146 146 %>
147 147 ```
148 148
149 - _Note: Image uploads are coming soon._
149 + ### Image Uploads
150 +
151 + Included in Thesis is an adapter for Ospry.io, which is a service that
152 + offers the first 1,000 images and 1 GB of monthly download bandwidth
153 + for free.
154 +
155 + 1. Sign up at [https://ospry.io/sign-up](https://ospry.io/sign-up)
156 + 2. Verify your email
157 + 3. Create a production subdomain (assets.example.com)
158 + 3. Copy your production public key to the Thesis config:
159 +
160 + ```elixir
161 + config :thesis, Thesis.OspryUploader,
162 + ospry_public_key: "pk-prod-abcdefghijklmnopqrstuvwxyz0123456789"
163 + ```
164 +
165 + That's it! Restart your server and image content areas will now contain a
166 + file upload field. _Note: You'll need to add a valid credit card if you
167 + anticipate exceeding Ospry.io limits._
150 168
151 169 ### Global Content Areas
152 170
  @@ -275,7 +293,7 @@ websites. Please help us improve!
275 293 1. Fork it
276 294 2. Create your feature branch (`git checkout -b my-new-feature`)
277 295 3. Commit your changes (`git commit -am 'Add some feature'`)
278 - 4. Run `brunch watch` during development
296 + 4. Run `brunch watch -p` during development
279 297 5. Write tests for your new feature
280 298 6. Run `mix test` in the root directory to ensure that all tests pass.
281 299 7. Push to the branch (`git push origin my-new-feature`)
  @@ -6,7 +6,7 @@ For automatic setup, see `README.md`.
6 6
7 7 ```elixir
8 8 def deps do
9 - [{:thesis, "~> 0.0.19"}]
9 + [{:thesis, "~> 0.0.20"}]
10 10 end
11 11
12 12 def application do
  @@ -23,6 +23,9 @@ config :thesis,
23 23 store: Thesis.EctoStore,
24 24 authorization: <MyApp>.ThesisAuth
25 25 config :thesis, Thesis.EctoStore, repo: <MyApp>.Repo
26 + # If you want to use Ospry.io file uploads:
27 + # config :thesis, Thesis.OspryUploader,
28 + # ospry_public_key: "pk-prod-asdfasdfasdfasdfasdf"
26 29 ```
27 30
28 31 #### 3. Create `lib/thesis_auth.ex`
  @@ -9,9 +9,12 @@
9 9 <<"lib/thesis/auth.ex">>,<<"lib/thesis/config.ex">>,
10 10 <<"lib/thesis/controller.ex">>,<<"lib/thesis/models/page.ex">>,
11 11 <<"lib/thesis/models/page_content.ex">>,<<"lib/thesis/render.ex">>,
12 - <<"lib/thesis/router.ex">>,<<"lib/thesis/store.ex">>,
13 - <<"lib/thesis/stores/ecto_store.ex">>,<<"lib/thesis/view.ex">>,
12 + <<"lib/thesis/router.ex">>,<<"lib/thesis/stores/ecto_store.ex">>,
13 + <<"lib/thesis/stores/store.ex">>,
14 + <<"lib/thesis/uploaders/ospry_uploader.ex">>,
15 + <<"lib/thesis/uploaders/uploader.ex">>,<<"lib/thesis/view.ex">>,
14 16 <<"priv/static/thesis-editor.js">>,<<"priv/static/thesis.css">>,
17 + <<"priv/templates/thesis.install/add_indexes_to_tables.exs">>,
15 18 <<"priv/templates/thesis.install/add_meta_to_thesis_page_contents.exs">>,
16 19 <<"priv/templates/thesis.install/create_thesis_tables.exs">>,
17 20 <<"priv/templates/thesis.install/thesis_auth.exs">>,
  @@ -124,11 +127,11 @@
124 127 <<"web/static/js/content_types/raw_html_tray.js">>,
125 128 <<"web/static/js/content_types/text_editor.js">>,
126 129 <<"web/static/js/thesis-editor.js">>,<<"web/static/js/utilities/net.js">>,
127 - <<"mix.exs">>,<<"README.md">>,<<"README_INSTALL.md">>,<<"LICENSE.md">>,
128 - <<"package.json">>]}.
130 + <<"web/static/js/utilities/ospry.js">>,<<"mix.exs">>,<<"README.md">>,
131 + <<"README_INSTALL.md">>,<<"LICENSE.md">>,<<"package.json">>]}.
129 132 {<<"licenses">>,[<<"MIT">>]}.
130 133 {<<"links">>,
131 - [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.19/api-reference.html">>},
134 + [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.20/api-reference.html">>},
132 135 {<<"GitHub">>,<<"https://github.com/infinite_red/thesis">>}]}.
133 136 {<<"maintainers">>,
134 137 [<<"Jamon Holmgren">>,<<"Ken Miller">>,<<"Daniel Berkompas">>]}.
  @@ -158,4 +161,4 @@
158 161 {<<"name">>,<<"html_sanitize_ex">>},
159 162 {<<"optional">>,false},
160 163 {<<"requirement">>,<<">= 1.0.1">>}]]}.
161 - {<<"version">>,<<"0.0.19">>}.
164 + {<<"version">>,<<"0.0.20">>}.
  @@ -2,6 +2,15 @@ defmodule Mix.Tasks.Thesis.Install do
2 2 use Mix.Task
3 3 import Mix.Thesis.Utils
4 4
5 + @migrations [
6 + "create_thesis_tables",
7 + "add_meta_to_thesis_page_contents",
8 + "add_indexes_to_tables"
9 + ]
10 + @template_files [
11 + {"priv/templates/thesis.install/thesis_auth.exs", "lib/thesis_auth.ex" }
12 + ]
13 +
5 14 @shortdoc "Generates Thesis code in your Phoenix app"
6 15
7 16 @moduledoc """
  @@ -29,13 +38,12 @@ defmodule Mix.Tasks.Thesis.Install do
29 38 @doc false
30 39 def thesis_templates do
31 40 migrations = ["create_thesis_tables", "add_meta_to_thesis_page_contents"]
32 - migration_files = Enum.filter_map(migrations, &migration_missing?/1, fn (filename) ->
33 - {"priv/templates/thesis.install/#{filename}.exs", "priv/repo/migrations/#{timestamp}_#{filename}.exs"}
34 - end)
41 + migration_files = @migrations
42 + |> Enum.filter(&migration_missing?/1)
43 + |> Enum.with_index
44 + |> Enum.map(&migration_tuple/1)
35 45
36 - template_files = [ {"priv/templates/thesis.install/thesis_auth.exs", "lib/thesis_auth.ex" } ]
37 -
38 - template_files ++ migration_files
46 + @template_files ++ migration_files
39 47 |> Stream.map(&render_eex/1)
40 48 |> Stream.map(&copy_to_target/1)
41 49 |> Stream.run
  @@ -90,6 +98,9 @@ defmodule Mix.Tasks.Thesis.Install do
90 98 store: Thesis.EctoStore,
91 99 authorization: #{Mix.Phoenix.base}.ThesisAuth
92 100 config :thesis, Thesis.EctoStore, repo: #{Mix.Phoenix.base}.Repo
101 + # If you want to use Ospry.io file uploads:
102 + # config :thesis, Thesis.OspryUploader,
103 + # ospry_public_key: "pk-prod-asdfasdfasdfasdfasdf"
93 104 """
94 105 else
95 106 status_msg("skipping", "thesis config. It already exists.")
  @@ -102,4 +113,9 @@ defmodule Mix.Tasks.Thesis.Install do
102 113 |> File.ls!
103 114 |> Enum.all?(fn (f) -> !String.contains?(f, filename) end)
104 115 end
116 +
117 + defp migration_tuple({filename, i}) do
118 + ts = String.to_integer(timestamp) + i
119 + {"priv/templates/thesis.install/#{filename}.exs", "priv/repo/migrations/#{ts}_#{filename}.exs"}
120 + end
105 121 end
  @@ -13,6 +13,10 @@ defmodule Thesis.Config do
13 13 Application.get_env(:thesis, Thesis.EctoStore)[:repo]
14 14 end
15 15
16 + def ospry_public_key do
17 + Application.get_env(:thesis, Thesis.OspryUploader)[:ospry_public_key]
18 + end
19 +
16 20 def thesis_js_source_path do
17 21 Path.join(Application.app_dir(:thesis), "priv/static/thesis-editor.js")
18 22 end
Loading more files…