Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.

Commit e4baab6

Browse files
Merge pull request #33 from infinitered/feature/file-upload
Added Ospry.io image uploading
2 parents 369e01e + 69e6852 commit e4baab6

File tree

18 files changed

+174
-29429
lines changed

18 files changed

+174
-29429
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,25 @@ becomes...
146146
%>
147147
```
148148

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._
150168

151169
### Global Content Areas
152170

@@ -275,7 +293,7 @@ websites. Please help us improve!
275293
1. Fork it
276294
2. Create your feature branch (`git checkout -b my-new-feature`)
277295
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
279297
5. Write tests for your new feature
280298
6. Run `mix test` in the root directory to ensure that all tests pass.
281299
7. Push to the branch (`git push origin my-new-feature`)

README_INSTALL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ config :thesis,
2323
store: Thesis.EctoStore,
2424
authorization: <MyApp>.ThesisAuth
2525
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"
2629
```
2730

2831
#### 3. Create `lib/thesis_auth.ex`

lib/mix/tasks/thesis.install.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ defmodule Mix.Tasks.Thesis.Install do
9191
store: Thesis.EctoStore,
9292
authorization: #{Mix.Phoenix.base}.ThesisAuth
9393
config :thesis, Thesis.EctoStore, repo: #{Mix.Phoenix.base}.Repo
94+
# If you want to use Ospry.io file uploads:
95+
# config :thesis, Thesis.OspryUploader,
96+
# ospry_public_key: "pk-prod-asdfasdfasdfasdfasdf"
9497
"""
9598
else
9699
status_msg("skipping", "thesis config. It already exists.")

lib/thesis/config.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ defmodule Thesis.Config do
1313
Application.get_env(:thesis, Thesis.EctoStore)[:repo]
1414
end
1515

16+
def ospry_public_key do
17+
Application.get_env(:thesis, Thesis.OspryUploader)[:ospry_public_key]
18+
end
19+
1620
def thesis_js_source_path do
1721
Path.join(Application.app_dir(:thesis), "priv/static/thesis-editor.js")
1822
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
defmodule Thesis.OspryUploader do
2+
@moduledoc """
3+
This is a placeholder for potential future server-side Ospry integration.
4+
"""
5+
6+
@behaviour Thesis.Uploader
7+
end

lib/thesis/uploaders/uploader.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule Thesis.Uploader do
2+
@moduledoc """
3+
Thesis.Uploader is an Elixir "behaviour" that defines the public function
4+
interface necessary for Thesis to upload files and images.
5+
6+
NOTE: This is under active development.
7+
8+
There are currently no required functions. Reserved for future use.
9+
"""
10+
end

lib/thesis/view.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ defmodule Thesis.View do
107107
@spec thesis_editor(Plug.Conn.t) :: {:safe, String.t}
108108
def thesis_editor(conn) do
109109
if editable?(conn) do
110-
editor = content_tag(:div, "", id: "thesis-container")
110+
editor = content_tag(:div, "", id: "thesis-container", data_ospry_public_key: ospry_public_key)
111111
safe_concat([thesis_style, editor, thesis_js])
112112
else
113113
raw ""

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"cowlib": {:hex, :cowlib, "1.0.2"},
33
"decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []},
44
"dialyze": {:hex, :dialyze, "0.2.1", "9fb71767f96649020d769db7cbd7290059daff23707d6e851e206b1fdfa92f9d", [:mix], []},
5-
"earmark": {:hex, :earmark, "0.2.1", "ba6d26ceb16106d069b289df66751734802777a3cbb6787026dd800ffeb850f3", [:mix], []},
5+
"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []},
66
"ecto": {:hex, :ecto, "2.0.2", "b02331c1f20bbe944dbd33c8ecd8f1ccffecc02e344c4471a891baf3a25f5406", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:postgrex, "~> 0.11.2", [hex: :postgrex, optional: true]}, {:db_connection, "~> 1.0-rc.2", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}]},
7-
"ex_doc": {:hex, :ex_doc, "0.12.0", "b774aabfede4af31c0301aece12371cbd25995a21bb3d71d66f5c2fe074c603f", [:mix], [{:earmark, "~> 0.2", [hex: :earmark, optional: false]}]},
7+
"ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
88
"html_sanitize_ex": {:hex, :html_sanitize_ex, "1.0.1", "2572e7122c78ab7e57b613e7c7f5e42bf9b3c25e430e32f23f1413d86db8a0af", [:mix], [{:mochiweb, "~> 2.12.2", [hex: :mochiweb, optional: false]}]},
99
"mochiweb": {:hex, :mochiweb, "2.12.2", "80804ad342afa3d7f3524040d4eed66ce74b17a555de454ac85b07c479928e46", [:make, :rebar], []},
1010
"phoenix": {:hex, :phoenix, "1.2.0", "1bdeb99c254f4c534cdf98fd201dede682297ccc62fcac5d57a2627c3b6681fb", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
11-
"phoenix_html": {:hex, :phoenix_html, "2.6.1", "7d53fb8d3d0a057a6eb3df24e7c5b86630d8d7495b13221537d9c4130d527d95", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
11+
"phoenix_html": {:hex, :phoenix_html, "2.6.2", "944a5e581b0d899e4f4c838a69503ebd05300fe35ba228a74439e6253e10e0c0", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
1212
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.0", "c31af4be22afeeebfaf246592778c8c840e5a1ddc7ca87610c41ccfb160c2c57", [:mix], []},
1313
"plug": {:hex, :plug, "1.1.6", "8927e4028433fcb859e000b9389ee9c37c80eb28378eeeea31b0273350bf668b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
1414
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
"version": "0.0.19-dev",
44
"main": "./priv/static/thesis.js",
55
"repository": {},
6-
"license" : "MIT",
6+
"license": "MIT",
77
"devDependencies": {
88
"babel-brunch": "~6.0.0",
99
"babel-preset-react": "^6.5.0",
1010
"brunch": "^2.8.2",
11+
"clean-css-brunch": "^2.0",
12+
"css-brunch": "^2.6",
1113
"medium-editor": "^5.14.4",
12-
"react": "0.14.7",
13-
"react-dom": "0.14.7",
14-
"whatwg-fetch": "^0.11.0",
15-
"clean-css-brunch": ">= 1.0 < 1.8",
16-
"css-brunch": ">= 1.0 < 1.8",
17-
"sass-brunch": "^1.9.1",
18-
"node-sass": "^3.4.1"
14+
"node-sass": "^3.4.1",
15+
"react": "15.2.1",
16+
"react-dom": "15.2.1",
17+
"sass-brunch": "^2.6.3",
18+
"uglify-js-brunch": "^2.0.1",
19+
"whatwg-fetch": "^1.0.0"
1920
},
2021
"files": [
2122
"package.json",

0 commit comments

Comments
 (0)