aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Ramos2020-02-04 16:06:14 +0100
committerGuillermo Ramos2020-02-04 16:06:14 +0100
commit4c399821684fa38b0d52b03932d7856b569478ab (patch)
tree1fdb87156f181c1936cedaa6783dd9acf2475df6
parent1566a2fcba0676cf54dde2b04702a320d9f1edcd (diff)
downloadwaev-4c399821684fa38b0d52b03932d7856b569478ab.tar.gz
Exports (WIP)
-rw-r--r--.gitignore2
-rw-r--r--README.md12
-rw-r--r--config/config.exs2
-rw-r--r--lib/waev/export.ex12
-rw-r--r--lib/waev_web/controllers/exports_controller.ex7
-rw-r--r--lib/waev_web/router.ex2
-rw-r--r--lib/waev_web/templates/exports/show.html.eex35
-rw-r--r--lib/waev_web/views/exports_view.ex3
8 files changed, 74 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index d981bba..5ef6e54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,5 @@ npm-debug.log
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/
+
+/exports \ No newline at end of file
diff --git a/README.md b/README.md
index c6d1b55..f4ad79c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,15 @@
# Waev (WhatsApp Exports Viewer)
+## Internal export format
+
+Each format is a folder inside `exports_path` with the following structure:
+
+ export1/
+ chat.txt
+ media/ (optional)
+
+## Auto generated stuff left here for reference
+
To start your Phoenix server:
* Install dependencies with `mix deps.get`
@@ -10,7 +20,7 @@ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).
-## Learn more
+### Learn more
* Official website: https://www.phoenixframework.org/
* Guides: https://hexdocs.pm/phoenix/overview.html
diff --git a/config/config.exs b/config/config.exs
index bc46e8b..db48b00 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -22,6 +22,8 @@ config :logger, :console,
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
+config :waev, Waev.Export, exports_path: "./exports"
+
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
diff --git a/lib/waev/export.ex b/lib/waev/export.ex
new file mode 100644
index 0000000..92a39c9
--- /dev/null
+++ b/lib/waev/export.ex
@@ -0,0 +1,12 @@
+defmodule Waev.Export do
+ def path do
+ Application.fetch_env!(:waev, __MODULE__)[:exports_path]
+ end
+
+ def list do
+ case File.ls(path()) do
+ {:error, _reason} -> []
+ {:ok, elems} -> Enum.filter(elems, &File.dir?/1)
+ end
+ end
+end
diff --git a/lib/waev_web/controllers/exports_controller.ex b/lib/waev_web/controllers/exports_controller.ex
new file mode 100644
index 0000000..a50896e
--- /dev/null
+++ b/lib/waev_web/controllers/exports_controller.ex
@@ -0,0 +1,7 @@
+defmodule WaevWeb.ExportsController do
+ use WaevWeb, :controller
+
+ def show(conn, %{"id" => id}) do
+ render(conn, "show.html", id: id)
+ end
+end
diff --git a/lib/waev_web/router.ex b/lib/waev_web/router.ex
index e98f87a..edd2c69 100644
--- a/lib/waev_web/router.ex
+++ b/lib/waev_web/router.ex
@@ -17,6 +17,8 @@ defmodule WaevWeb.Router do
pipe_through :browser
get "/", PageController, :index
+ # index,edit,new,show,create,update
+ resources "/exports", ExportsController, only: [:show]
end
# Other scopes may use custom stacks.
diff --git a/lib/waev_web/templates/exports/show.html.eex b/lib/waev_web/templates/exports/show.html.eex
new file mode 100644
index 0000000..4351a17
--- /dev/null
+++ b/lib/waev_web/templates/exports/show.html.eex
@@ -0,0 +1,35 @@
+ID: <%= @id %>
+
+<section class="phx-hero">
+ <section class="row">
+ <article class="column">
+ <h2>Left</h2>
+ <ul>
+ <li>
+ <a href="#">Link 1</a>
+ </li>
+ <li>
+ Text 2
+ </li>
+ <li>
+ Text 3
+ </li>
+ </ul>
+ </article>
+ <article class="column">
+ <h2>Right</h2>
+ <ul>
+ <li>
+ <a href="#">Link 1</a>
+ </li>
+ <li>
+ Text 2
+ </li>
+ <li>
+ Text 3
+ </li>
+ </ul>
+ </article>
+ </section>
+</section>
+
diff --git a/lib/waev_web/views/exports_view.ex b/lib/waev_web/views/exports_view.ex
new file mode 100644
index 0000000..c4b637f
--- /dev/null
+++ b/lib/waev_web/views/exports_view.ex
@@ -0,0 +1,3 @@
+defmodule WaevWeb.ExportsView do
+ use WaevWeb, :view
+end