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

Commit

Permalink
Merge pull request #33 from infinitered/feature/file-upload
Browse files Browse the repository at this point in the history
Added Ospry.io image uploading
  • Loading branch information
jamonholmgren authored Jul 19, 2016
2 parents 369e01e + 69e6852 commit e4baab6
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 29,429 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,25 @@ becomes...
%>
```

_Note: Image uploads are coming soon._
### Image Uploads

Included in Thesis is an adapter for Ospry.io, which is a service that
offers the first 1,000 images and 1 GB of monthly download bandwidth
for free.

1. # at [https://ospry.io/sign-up](https://ospry.io/sign-up)
2. Verify your email
3. Create a production subdomain (assets.example.com)
3. Copy your production public key to the Thesis config:

```elixir
config :thesis, Thesis.OspryUploader,
ospry_public_key: "pk-prod-abcdefghijklmnopqrstuvwxyz0123456789"
```

That's it! Restart your server and image content areas will now contain a
file upload field. _Note: You'll need to add a valid credit card if you
anticipate exceeding Ospry.io limits._

### Global Content Areas

Expand Down Expand Up @@ -275,7 +293,7 @@ websites. Please help us improve!
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Run `brunch watch` during development
4. Run `brunch watch -p` during development
5. Write tests for your new feature
6. Run `mix test` in the root directory to ensure that all tests pass.
7. Push to the branch (`git push origin my-new-feature`)
Expand Down
3 changes: 3 additions & 0 deletions README_INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ config :thesis,
store: Thesis.EctoStore,
authorization: <MyApp>.ThesisAuth
config :thesis, Thesis.EctoStore, repo: <MyApp>.Repo
# If you want to use Ospry.io file uploads:
# config :thesis, Thesis.OspryUploader,
# ospry_public_key: "pk-prod-asdfasdfasdfasdfasdf"
```

#### 3. Create `lib/thesis_auth.ex`
Expand Down
3 changes: 3 additions & 0 deletions lib/mix/tasks/thesis.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ defmodule Mix.Tasks.Thesis.Install do
store: Thesis.EctoStore,
authorization: #{Mix.Phoenix.base}.ThesisAuth
config :thesis, Thesis.EctoStore, repo: #{Mix.Phoenix.base}.Repo
# If you want to use Ospry.io file uploads:
# config :thesis, Thesis.OspryUploader,
# ospry_public_key: "pk-prod-asdfasdfasdfasdfasdf"
"""
else
status_msg("skipping", "thesis config. It already exists.")
Expand Down
4 changes: 4 additions & 0 deletions lib/thesis/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ defmodule Thesis.Config do
Application.get_env(:thesis, Thesis.EctoStore)[:repo]
end

def ospry_public_key do
Application.get_env(:thesis, Thesis.OspryUploader)[:ospry_public_key]
end

def thesis_js_source_path do
Path.join(Application.app_dir(:thesis), "priv/static/thesis-editor.js")
end
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions lib/thesis/uploaders/ospry_uploader.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Thesis.OspryUploader do
@moduledoc """
This is a placeholder for potential future server-side Ospry integration.
"""

@behaviour Thesis.Uploader
end
10 changes: 10 additions & 0 deletions lib/thesis/uploaders/uploader.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule Thesis.Uploader do
@moduledoc """
Thesis.Uploader is an Elixir "behaviour" that defines the public function
interface necessary for Thesis to upload files and images.
NOTE: This is under active development.
There are currently no required functions. Reserved for future use.
"""
end
2 changes: 1 addition & 1 deletion lib/thesis/view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ defmodule Thesis.View do
@spec thesis_editor(Plug.Conn.t) :: {:safe, String.t}
def thesis_editor(conn) do
if editable?(conn) do
editor = content_tag(:div, "", id: "thesis-container")
editor = content_tag(:div, "", id: "thesis-container", data_ospry_public_key: ospry_public_key)
safe_concat([thesis_style, editor, thesis_js])
else
raw ""
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"cowlib": {:hex, :cowlib, "1.0.2"},
"decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []},
"dialyze": {:hex, :dialyze, "0.2.1", "9fb71767f96649020d769db7cbd7290059daff23707d6e851e206b1fdfa92f9d", [:mix], []},
"earmark": {:hex, :earmark, "0.2.1", "ba6d26ceb16106d069b289df66751734802777a3cbb6787026dd800ffeb850f3", [:mix], []},
"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []},
"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]}]},
"ex_doc": {:hex, :ex_doc, "0.12.0", "b774aabfede4af31c0301aece12371cbd25995a21bb3d71d66f5c2fe074c603f", [:mix], [{:earmark, "~> 0.2", [hex: :earmark, optional: false]}]},
"ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
"html_sanitize_ex": {:hex, :html_sanitize_ex, "1.0.1", "2572e7122c78ab7e57b613e7c7f5e42bf9b3c25e430e32f23f1413d86db8a0af", [:mix], [{:mochiweb, "~> 2.12.2", [hex: :mochiweb, optional: false]}]},
"mochiweb": {:hex, :mochiweb, "2.12.2", "80804ad342afa3d7f3524040d4eed66ce74b17a555de454ac85b07c479928e46", [:make, :rebar], []},
"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]}]},
"phoenix_html": {:hex, :phoenix_html, "2.6.1", "7d53fb8d3d0a057a6eb3df24e7c5b86630d8d7495b13221537d9c4130d527d95", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
"phoenix_html": {:hex, :phoenix_html, "2.6.2", "944a5e581b0d899e4f4c838a69503ebd05300fe35ba228a74439e6253e10e0c0", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.0", "c31af4be22afeeebfaf246592778c8c840e5a1ddc7ca87610c41ccfb160c2c57", [:mix], []},
"plug": {:hex, :plug, "1.1.6", "8927e4028433fcb859e000b9389ee9c37c80eb28378eeeea31b0273350bf668b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
"version": "0.0.19-dev",
"main": "./priv/static/thesis.js",
"repository": {},
"license" : "MIT",
"license": "MIT",
"devDependencies": {
"babel-brunch": "~6.0.0",
"babel-preset-react": "^6.5.0",
"brunch": "^2.8.2",
"clean-css-brunch": "^2.0",
"css-brunch": "^2.6",
"medium-editor": "^5.14.4",
"react": "0.14.7",
"react-dom": "0.14.7",
"whatwg-fetch": "^0.11.0",
"clean-css-brunch": ">= 1.0 < 1.8",
"css-brunch": ">= 1.0 < 1.8",
"sass-brunch": "^1.9.1",
"node-sass": "^3.4.1"
"node-sass": "^3.4.1",
"react": "15.2.1",
"react-dom": "15.2.1",
"sass-brunch": "^2.6.3",
"uglify-js-brunch": "^2.0.1",
"whatwg-fetch": "^1.0.0"
},
"files": [
"package.json",
Expand Down
Loading

0 comments on commit e4baab6

Please # to comment.