From 4c399821684fa38b0d52b03932d7856b569478ab Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Tue, 4 Feb 2020 16:06:14 +0100 Subject: Exports (WIP) --- .gitignore | 2 ++ README.md | 12 ++++++++- config/config.exs | 2 ++ lib/waev/export.ex | 12 +++++++++ lib/waev_web/controllers/exports_controller.ex | 7 ++++++ lib/waev_web/router.ex | 2 ++ lib/waev_web/templates/exports/show.html.eex | 35 ++++++++++++++++++++++++++ lib/waev_web/views/exports_view.ex | 3 +++ 8 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 lib/waev/export.ex create mode 100644 lib/waev_web/controllers/exports_controller.ex create mode 100644 lib/waev_web/templates/exports/show.html.eex create mode 100644 lib/waev_web/views/exports_view.ex 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 %> + +
+
+
+

Left

+
    +
  • + Link 1 +
  • +
  • + Text 2 +
  • +
  • + Text 3 +
  • +
+
+
+

Right

+
    +
  • + Link 1 +
  • +
  • + Text 2 +
  • +
  • + Text 3 +
  • +
+
+
+
+ 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 -- cgit v1.2.3