Resources
+-
+
- + Guides & Docs + +
- + Source + +
- + v1.5 Changelog + +
diff --git a/dummy/.formatter.exs b/dummy/.formatter.exs
new file mode 100644
index 0000000..8a6391c
--- /dev/null
+++ b/dummy/.formatter.exs
@@ -0,0 +1,5 @@
+[
+ import_deps: [:ecto, :phoenix],
+ inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
+ subdirectories: ["priv/*/migrations"]
+]
diff --git a/dummy/.gitignore b/dummy/.gitignore
new file mode 100644
index 0000000..929bfab
--- /dev/null
+++ b/dummy/.gitignore
@@ -0,0 +1,34 @@
+# The directory Mix will write compiled artifacts to.
+/_build/
+
+# If you run "mix test --cover", coverage assets end up here.
+/cover/
+
+# The directory Mix downloads your dependencies sources to.
+/deps/
+
+# Where 3rd-party dependencies like ExDoc output generated docs.
+/doc/
+
+# Ignore .fetch files in case you like to edit your project deps locally.
+/.fetch
+
+# If the VM crashes, it generates a dump, let's ignore it too.
+erl_crash.dump
+
+# Also ignore archive artifacts (built via "mix archive.build").
+*.ez
+
+# Ignore package tarball (built via "mix hex.build").
+dummy-*.tar
+
+# If NPM crashes, it generates a log, let's ignore it too.
+npm-debug.log
+
+# The directory NPM downloads your dependencies sources to.
+/assets/node_modules/
+
+# Since we are building assets from assets/,
+# we ignore priv/static. You may want to comment
+# this depending on your deployment strategy.
+/priv/static/
diff --git a/dummy/README.md b/dummy/README.md
new file mode 100644
index 0000000..ce09b2f
--- /dev/null
+++ b/dummy/README.md
@@ -0,0 +1 @@
+# Dummy
\ No newline at end of file
diff --git a/dummy/assets/.babelrc b/dummy/assets/.babelrc
new file mode 100644
index 0000000..ce33b24
--- /dev/null
+++ b/dummy/assets/.babelrc
@@ -0,0 +1,5 @@
+{
+ "presets": [
+ "@babel/preset-env"
+ ]
+}
diff --git a/dummy/assets/css/app.scss b/dummy/assets/css/app.scss
new file mode 100644
index 0000000..f7775db
--- /dev/null
+++ b/dummy/assets/css/app.scss
@@ -0,0 +1,91 @@
+/* This file is for your main application css. */
+@import "./phoenix.css";
+@import "../node_modules/nprogress/nprogress.css";
+
+/* LiveView specific classes for your customizations */
+.phx-no-feedback.invalid-feedback,
+.phx-no-feedback .invalid-feedback {
+ display: none;
+}
+
+.phx-click-loading {
+ opacity: 0.5;
+ transition: opacity 1s ease-out;
+}
+
+.phx-disconnected{
+ cursor: wait;
+}
+.phx-disconnected *{
+ pointer-events: none;
+}
+
+.phx-modal {
+ opacity: 1!important;
+ position: fixed;
+ z-index: 1;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ overflow: auto;
+ background-color: rgb(0,0,0);
+ background-color: rgba(0,0,0,0.4);
+}
+
+.phx-modal-content {
+ background-color: #fefefe;
+ margin: 15% auto;
+ padding: 20px;
+ border: 1px solid #888;
+ width: 80%;
+}
+
+.phx-modal-close {
+ color: #aaa;
+ float: right;
+ font-size: 28px;
+ font-weight: bold;
+}
+
+.phx-modal-close:hover,
+.phx-modal-close:focus {
+ color: black;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+
+/* Alerts and form errors */
+.alert {
+ padding: 15px;
+ margin-bottom: 20px;
+ border: 1px solid transparent;
+ border-radius: 4px;
+}
+.alert-info {
+ color: #31708f;
+ background-color: #d9edf7;
+ border-color: #bce8f1;
+}
+.alert-warning {
+ color: #8a6d3b;
+ background-color: #fcf8e3;
+ border-color: #faebcc;
+}
+.alert-danger {
+ color: #a94442;
+ background-color: #f2dede;
+ border-color: #ebccd1;
+}
+.alert p {
+ margin-bottom: 0;
+}
+.alert:empty {
+ display: none;
+}
+.invalid-feedback {
+ color: #a94442;
+ display: block;
+ margin: -1rem 0 2rem;
+}
diff --git a/dummy/assets/css/phoenix.css b/dummy/assets/css/phoenix.css
new file mode 100644
index 0000000..3767b31
--- /dev/null
+++ b/dummy/assets/css/phoenix.css
@@ -0,0 +1,101 @@
+/* Includes some default style for the starter application.
+ * This can be safely deleted to start fresh.
+ */
+
+/* Milligram v1.3.0 https://milligram.github.io
+ * Copyright (c) 2017 CJ Patoilo Licensed under the MIT license
+ */
+
+*,*:after,*:before{box-sizing:inherit}html{box-sizing:border-box;font-size:62.5%}body{color:#000000;font-family:'Helvetica', 'Arial', sans-serif;font-size:1.6em;font-weight:300;line-height:1.6}blockquote{border-left:0.3rem solid #d1d1d1;margin-left:0;margin-right:0;padding:1rem 1.5rem}blockquote *:last-child{margin-bottom:0}.button,button,input[type='button'],input[type='reset'],input[type='submit']{background-color:#0069d9;border:0.1rem solid #0069d9;border-radius:.4rem;color:#fff;cursor:pointer;display:inline-block;font-size:1.1rem;font-weight:700;height:3.8rem;letter-spacing:.1rem;line-height:3.8rem;padding:0 3.0rem;text-align:center;text-decoration:none;text-transform:uppercase;white-space:nowrap}.button:focus,.button:hover,button:focus,button:hover,input[type='button']:focus,input[type='button']:hover,input[type='reset']:focus,input[type='reset']:hover,input[type='submit']:focus,input[type='submit']:hover{background-color:#606c76;border-color:#606c76;color:#fff;outline:0}.button[disabled],button[disabled],input[type='button'][disabled],input[type='reset'][disabled],input[type='submit'][disabled]{cursor:default;opacity:.5}.button[disabled]:focus,.button[disabled]:hover,button[disabled]:focus,button[disabled]:hover,input[type='button'][disabled]:focus,input[type='button'][disabled]:hover,input[type='reset'][disabled]:focus,input[type='reset'][disabled]:hover,input[type='submit'][disabled]:focus,input[type='submit'][disabled]:hover{background-color:#0069d9;border-color:#0069d9}.button.button-outline,button.button-outline,input[type='button'].button-outline,input[type='reset'].button-outline,input[type='submit'].button-outline{background-color:transparent;color:#0069d9}.button.button-outline:focus,.button.button-outline:hover,button.button-outline:focus,button.button-outline:hover,input[type='button'].button-outline:focus,input[type='button'].button-outline:hover,input[type='reset'].button-outline:focus,input[type='reset'].button-outline:hover,input[type='submit'].button-outline:focus,input[type='submit'].button-outline:hover{background-color:transparent;border-color:#606c76;color:#606c76}.button.button-outline[disabled]:focus,.button.button-outline[disabled]:hover,button.button-outline[disabled]:focus,button.button-outline[disabled]:hover,input[type='button'].button-outline[disabled]:focus,input[type='button'].button-outline[disabled]:hover,input[type='reset'].button-outline[disabled]:focus,input[type='reset'].button-outline[disabled]:hover,input[type='submit'].button-outline[disabled]:focus,input[type='submit'].button-outline[disabled]:hover{border-color:inherit;color:#0069d9}.button.button-clear,button.button-clear,input[type='button'].button-clear,input[type='reset'].button-clear,input[type='submit'].button-clear{background-color:transparent;border-color:transparent;color:#0069d9}.button.button-clear:focus,.button.button-clear:hover,button.button-clear:focus,button.button-clear:hover,input[type='button'].button-clear:focus,input[type='button'].button-clear:hover,input[type='reset'].button-clear:focus,input[type='reset'].button-clear:hover,input[type='submit'].button-clear:focus,input[type='submit'].button-clear:hover{background-color:transparent;border-color:transparent;color:#606c76}.button.button-clear[disabled]:focus,.button.button-clear[disabled]:hover,button.button-clear[disabled]:focus,button.button-clear[disabled]:hover,input[type='button'].button-clear[disabled]:focus,input[type='button'].button-clear[disabled]:hover,input[type='reset'].button-clear[disabled]:focus,input[type='reset'].button-clear[disabled]:hover,input[type='submit'].button-clear[disabled]:focus,input[type='submit'].button-clear[disabled]:hover{color:#0069d9}code{background:#f4f5f6;border-radius:.4rem;font-size:86%;margin:0 .2rem;padding:.2rem .5rem;white-space:nowrap}pre{background:#f4f5f6;border-left:0.3rem solid #0069d9;overflow-y:hidden}pre>code{border-radius:0;display:block;padding:1rem 1.5rem;white-space:pre}hr{border:0;border-top:0.1rem solid #f4f5f6;margin:3.0rem 0}input[type='email'],input[type='number'],input[type='password'],input[type='search'],input[type='tel'],input[type='text'],input[type='url'],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0.1rem solid #d1d1d1;border-radius:.4rem;box-shadow:none;box-sizing:inherit;height:3.8rem;padding:.6rem 1.0rem;width:100%}input[type='email']:focus,input[type='number']:focus,input[type='password']:focus,input[type='search']:focus,input[type='tel']:focus,input[type='text']:focus,input[type='url']:focus,textarea:focus,select:focus{border-color:#0069d9;outline:0}select{background:url('data:image/svg+xml;utf8,') center right no-repeat;padding-right:3.0rem}select:focus{background-image:url('data:image/svg+xml;utf8,')}textarea{min-height:6.5rem}label,legend{display:block;font-size:1.6rem;font-weight:700;margin-bottom:.5rem}fieldset{border-width:0;padding:0}input[type='checkbox'],input[type='radio']{display:inline}.label-inline{display:inline-block;font-weight:normal;margin-left:.5rem}.row{display:flex;flex-direction:column;padding:0;width:100%}.row.row-no-padding{padding:0}.row.row-no-padding>.column{padding:0}.row.row-wrap{flex-wrap:wrap}.row.row-top{align-items:flex-start}.row.row-bottom{align-items:flex-end}.row.row-center{align-items:center}.row.row-stretch{align-items:stretch}.row.row-baseline{align-items:baseline}.row .column{display:block;flex:1 1 auto;margin-left:0;max-width:100%;width:100%}.row .column.column-offset-10{margin-left:10%}.row .column.column-offset-20{margin-left:20%}.row .column.column-offset-25{margin-left:25%}.row .column.column-offset-33,.row .column.column-offset-34{margin-left:33.3333%}.row .column.column-offset-50{margin-left:50%}.row .column.column-offset-66,.row .column.column-offset-67{margin-left:66.6666%}.row .column.column-offset-75{margin-left:75%}.row .column.column-offset-80{margin-left:80%}.row .column.column-offset-90{margin-left:90%}.row .column.column-10{flex:0 0 10%;max-width:10%}.row .column.column-20{flex:0 0 20%;max-width:20%}.row .column.column-25{flex:0 0 25%;max-width:25%}.row .column.column-33,.row .column.column-34{flex:0 0 33.3333%;max-width:33.3333%}.row .column.column-40{flex:0 0 40%;max-width:40%}.row .column.column-50{flex:0 0 50%;max-width:50%}.row .column.column-60{flex:0 0 60%;max-width:60%}.row .column.column-66,.row .column.column-67{flex:0 0 66.6666%;max-width:66.6666%}.row .column.column-75{flex:0 0 75%;max-width:75%}.row .column.column-80{flex:0 0 80%;max-width:80%}.row .column.column-90{flex:0 0 90%;max-width:90%}.row .column .column-top{align-self:flex-start}.row .column .column-bottom{align-self:flex-end}.row .column .column-center{-ms-grid-row-align:center;align-self:center}@media (min-width: 40rem){.row{flex-direction:row;margin-left:-1.0rem;width:calc(100% + 2.0rem)}.row .column{margin-bottom:inherit;padding:0 1.0rem}}a{color:#0069d9;text-decoration:none}a:focus,a:hover{color:#606c76}dl,ol,ul{list-style:none;margin-top:0;padding-left:0}dl dl,dl ol,dl ul,ol dl,ol ol,ol ul,ul dl,ul ol,ul ul{font-size:90%;margin:1.5rem 0 1.5rem 3.0rem}ol{list-style:decimal inside}ul{list-style:circle inside}.button,button,dd,dt,li{margin-bottom:1.0rem}fieldset,input,select,textarea{margin-bottom:1.5rem}blockquote,dl,figure,form,ol,p,pre,table,ul{margin-bottom:2.5rem}table{border-spacing:0;width:100%}td,th{border-bottom:0.1rem solid #e1e1e1;padding:1.2rem 1.5rem;text-align:left}td:first-child,th:first-child{padding-left:0}td:last-child,th:last-child{padding-right:0}b,strong{font-weight:bold}p{margin-top:0}h1,h2,h3,h4,h5,h6{font-weight:300;letter-spacing:-.1rem;margin-bottom:2.0rem;margin-top:0}h1{font-size:4.6rem;line-height:1.2}h2{font-size:3.6rem;line-height:1.25}h3{font-size:2.8rem;line-height:1.3}h4{font-size:2.2rem;letter-spacing:-.08rem;line-height:1.35}h5{font-size:1.8rem;letter-spacing:-.05rem;line-height:1.5}h6{font-size:1.6rem;letter-spacing:0;line-height:1.4}img{max-width:100%}.clearfix:after{clear:both;content:' ';display:table}.float-left{float:left}.float-right{float:right}
+
+/* General style */
+h1{font-size: 3.6rem; line-height: 1.25}
+h2{font-size: 2.8rem; line-height: 1.3}
+h3{font-size: 2.2rem; letter-spacing: -.08rem; line-height: 1.35}
+h4{font-size: 1.8rem; letter-spacing: -.05rem; line-height: 1.5}
+h5{font-size: 1.6rem; letter-spacing: 0; line-height: 1.4}
+h6{font-size: 1.4rem; letter-spacing: 0; line-height: 1.2}
+pre{padding: 1em;}
+
+.container{
+ margin: 0 auto;
+ max-width: 80.0rem;
+ padding: 0 2.0rem;
+ position: relative;
+ width: 100%
+}
+select {
+ width: auto;
+}
+
+/* Phoenix promo and logo */
+.phx-hero {
+ text-align: center;
+ border-bottom: 1px solid #e3e3e3;
+ background: #eee;
+ border-radius: 6px;
+ padding: 3em 3em 1em;
+ margin-bottom: 3rem;
+ font-weight: 200;
+ font-size: 120%;
+}
+.phx-hero input {
+ background: #ffffff;
+}
+.phx-logo {
+ min-width: 300px;
+ margin: 1rem;
+ display: block;
+}
+.phx-logo img {
+ width: auto;
+ display: block;
+}
+
+/* Headers */
+header {
+ width: 100%;
+ background: #fdfdfd;
+ border-bottom: 1px solid #eaeaea;
+ margin-bottom: 2rem;
+}
+header section {
+ align-items: center;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+}
+header section :first-child {
+ order: 2;
+}
+header section :last-child {
+ order: 1;
+}
+header nav ul,
+header nav li {
+ margin: 0;
+ padding: 0;
+ display: block;
+ text-align: right;
+ white-space: nowrap;
+}
+header nav ul {
+ margin: 1rem;
+ margin-top: 0;
+}
+header nav a {
+ display: block;
+}
+
+@media (min-width: 40.0rem) { /* Small devices (landscape phones, 576px and up) */
+ header section {
+ flex-direction: row;
+ }
+ header nav ul {
+ margin: 1rem;
+ }
+ .phx-logo {
+ flex-basis: 527px;
+ margin: 2rem 1rem;
+ }
+}
diff --git a/dummy/assets/js/app.js b/dummy/assets/js/app.js
new file mode 100644
index 0000000..dfc0f97
--- /dev/null
+++ b/dummy/assets/js/app.js
@@ -0,0 +1,35 @@
+// We need to import the CSS so that webpack will load it.
+// The MiniCssExtractPlugin is used to separate it out into
+// its own CSS file.
+import "../css/app.scss"
+
+// webpack automatically bundles all modules in your
+// entry points. Those entry points can be configured
+// in "webpack.config.js".
+//
+// Import deps with the dep name or local files with a relative path, for example:
+//
+// import {Socket} from "phoenix"
+// import socket from "./socket"
+//
+import "phoenix_html"
+import {Socket} from "phoenix"
+import NProgress from "nprogress"
+import {LiveSocket} from "phoenix_live_view"
+
+let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
+let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
+
+// Show progress bar on live navigation and form submits
+window.addEventListener("phx:page-loading-start", info => NProgress.start())
+window.addEventListener("phx:page-loading-stop", info => NProgress.done())
+
+// connect if there are any LiveViews on the page
+liveSocket.connect()
+
+// expose liveSocket on window for web console debug logs and latency simulation:
+// >> liveSocket.enableDebug()
+// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
+// >> liveSocket.disableLatencySim()
+window.liveSocket = liveSocket
+
diff --git a/dummy/assets/package.json b/dummy/assets/package.json
new file mode 100644
index 0000000..aa41dee
--- /dev/null
+++ b/dummy/assets/package.json
@@ -0,0 +1,30 @@
+{
+ "repository": {},
+ "description": " ",
+ "license": "MIT",
+ "scripts": {
+ "deploy": "webpack --mode production",
+ "watch": "webpack --mode development --watch"
+ },
+ "dependencies": {
+ "phoenix": "file:../deps/phoenix",
+ "phoenix_html": "file:../deps/phoenix_html",
+ "phoenix_live_view": "file:../deps/phoenix_live_view",
+ "nprogress": "^0.2.0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.0.0",
+ "@babel/preset-env": "^7.0.0",
+ "babel-loader": "^8.0.0",
+ "copy-webpack-plugin": "^5.1.1",
+ "css-loader": "^3.4.2",
+ "sass-loader": "^8.0.2",
+ "node-sass": "^4.13.1",
+ "hard-source-webpack-plugin": "^0.13.1",
+ "mini-css-extract-plugin": "^0.9.0",
+ "optimize-css-assets-webpack-plugin": "^5.0.1",
+ "terser-webpack-plugin": "^2.3.2",
+ "webpack": "4.41.5",
+ "webpack-cli": "^3.3.2"
+ }
+}
diff --git a/dummy/assets/static/favicon.ico b/dummy/assets/static/favicon.ico
new file mode 100644
index 0000000..73de524
Binary files /dev/null and b/dummy/assets/static/favicon.ico differ
diff --git a/dummy/assets/static/images/phoenix.png b/dummy/assets/static/images/phoenix.png
new file mode 100644
index 0000000..9c81075
Binary files /dev/null and b/dummy/assets/static/images/phoenix.png differ
diff --git a/dummy/assets/static/robots.txt b/dummy/assets/static/robots.txt
new file mode 100644
index 0000000..3c9c7c0
--- /dev/null
+++ b/dummy/assets/static/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-agent: *
+# Disallow: /
diff --git a/dummy/assets/webpack.config.js b/dummy/assets/webpack.config.js
new file mode 100644
index 0000000..079610d
--- /dev/null
+++ b/dummy/assets/webpack.config.js
@@ -0,0 +1,53 @@
+const path = require('path');
+const glob = require('glob');
+const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
+const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
+const CopyWebpackPlugin = require('copy-webpack-plugin');
+
+module.exports = (env, options) => {
+ const devMode = options.mode !== 'production';
+
+ return {
+ optimization: {
+ minimizer: [
+ new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
+ new OptimizeCSSAssetsPlugin({})
+ ]
+ },
+ entry: {
+ 'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
+ },
+ output: {
+ filename: '[name].js',
+ path: path.resolve(__dirname, '../priv/static/js'),
+ publicPath: '/js/'
+ },
+ devtool: devMode ? 'eval-cheap-module-source-map' : undefined,
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ exclude: /node_modules/,
+ use: {
+ loader: 'babel-loader'
+ }
+ },
+ {
+ test: /\.[s]?css$/,
+ use: [
+ MiniCssExtractPlugin.loader,
+ 'css-loader',
+ 'sass-loader',
+ ],
+ }
+ ]
+ },
+ plugins: [
+ new MiniCssExtractPlugin({ filename: '../css/app.css' }),
+ new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
+ ]
+ .concat(devMode ? [new HardSourceWebpackPlugin()] : [])
+ }
+};
diff --git a/dummy/config/config.exs b/dummy/config/config.exs
new file mode 100644
index 0000000..7cbae8c
--- /dev/null
+++ b/dummy/config/config.exs
@@ -0,0 +1,36 @@
+# This file is responsible for configuring your application
+# and its dependencies with the aid of the Mix.Config module.
+#
+# This configuration file is loaded before any dependency and
+# is restricted to this project.
+
+# General application configuration
+use Mix.Config
+
+config :dummy,
+ ecto_repos: [Dummy.Repo]
+
+config :turbo_ecto, Turbo.Ecto,
+ repo: Dummy.Repo,
+ per_page: 10,
+ entry_name: "entries"
+
+# Configures the endpoint
+config :dummy, DummyWeb.Endpoint,
+ url: [host: "localhost"],
+ secret_key_base: "BuDdd474ra2KhjAu8LzSplS8Bm79HO5QWE53oL3rfvowoxkZOBLv5Rp1jG/SKMJe",
+ render_errors: [view: DummyWeb.ErrorView, accepts: ~w(html json), layout: false],
+ pubsub_server: Dummy.PubSub,
+ live_view: [signing_salt: "LOD7E3Yl"]
+
+# Configures Elixir's Logger
+config :logger, :console,
+ format: "$time $metadata[$level] $message\n",
+ metadata: [:request_id]
+
+# Use Jason for JSON parsing in Phoenix
+config :phoenix, :json_library, Jason
+
+# 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/dummy/config/dev.exs b/dummy/config/dev.exs
new file mode 100644
index 0000000..239b2da
--- /dev/null
+++ b/dummy/config/dev.exs
@@ -0,0 +1,76 @@
+use Mix.Config
+
+# Configure your database
+config :dummy, Dummy.Repo,
+ username: "postgres",
+ password: "postgres",
+ database: "dummy_dev",
+ hostname: "localhost",
+ show_sensitive_data_on_connection_error: true,
+ pool_size: 10
+
+# For development, we disable any cache and enable
+# debugging and code reloading.
+#
+# The watchers configuration can be used to run external
+# watchers to your application. For example, we use it
+# with webpack to recompile .js and .css sources.
+config :dummy, DummyWeb.Endpoint,
+ http: [port: 4000],
+ debug_errors: true,
+ code_reloader: true,
+ check_origin: false,
+ watchers: [
+ node: [
+ "node_modules/webpack/bin/webpack.js",
+ "--mode",
+ "development",
+ "--watch-stdin",
+ cd: Path.expand("../assets", __DIR__)
+ ]
+ ]
+
+# ## SSL Support
+#
+# In order to use HTTPS in development, a self-signed
+# certificate can be generated by running the following
+# Mix task:
+#
+# mix phx.gen.cert
+#
+# Note that this task requires Erlang/OTP 20 or later.
+# Run `mix help phx.gen.cert` for more information.
+#
+# The `http:` config above can be replaced with:
+#
+# https: [
+# port: 4001,
+# cipher_suite: :strong,
+# keyfile: "priv/cert/selfsigned_key.pem",
+# certfile: "priv/cert/selfsigned.pem"
+# ],
+#
+# If desired, both `http:` and `https:` keys can be
+# configured to run both http and https servers on
+# different ports.
+
+# Watch static and templates for browser reloading.
+config :dummy, DummyWeb.Endpoint,
+ live_reload: [
+ patterns: [
+ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
+ ~r"priv/gettext/.*(po)$",
+ ~r"lib/dummy_web/(live|views)/.*(ex)$",
+ ~r"lib/dummy_web/templates/.*(eex)$"
+ ]
+ ]
+
+# Do not include metadata nor timestamps in development logs
+config :logger, :console, format: "[$level] $message\n"
+
+# Set a higher stacktrace during development. Avoid configuring such
+# in production as building large stacktraces may be expensive.
+config :phoenix, :stacktrace_depth, 20
+
+# Initialize plugs at runtime for faster development compilation
+config :phoenix, :plug_init_mode, :runtime
diff --git a/dummy/config/prod.exs b/dummy/config/prod.exs
new file mode 100644
index 0000000..ecdff27
--- /dev/null
+++ b/dummy/config/prod.exs
@@ -0,0 +1,55 @@
+use Mix.Config
+
+# For production, don't forget to configure the url host
+# to something meaningful, Phoenix uses this information
+# when generating URLs.
+#
+# Note we also include the path to a cache manifest
+# containing the digested version of static files. This
+# manifest is generated by the `mix phx.digest` task,
+# which you should run after static files are built and
+# before starting your production server.
+config :dummy, DummyWeb.Endpoint,
+ url: [host: "example.com", port: 80],
+ cache_static_manifest: "priv/static/cache_manifest.json"
+
+# Do not print debug messages in production
+config :logger, level: :info
+
+# ## SSL Support
+#
+# To get SSL working, you will need to add the `https` key
+# to the previous section and set your `:url` port to 443:
+#
+# config :dummy, DummyWeb.Endpoint,
+# ...
+# url: [host: "example.com", port: 443],
+# https: [
+# port: 443,
+# cipher_suite: :strong,
+# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
+# certfile: System.get_env("SOME_APP_SSL_CERT_PATH"),
+# transport_options: [socket_opts: [:inet6]]
+# ]
+#
+# The `cipher_suite` is set to `:strong` to support only the
+# latest and more secure SSL ciphers. This means old browsers
+# and clients may not be supported. You can set it to
+# `:compatible` for wider support.
+#
+# `:keyfile` and `:certfile` expect an absolute path to the key
+# and cert in disk or a relative path inside priv, for example
+# "priv/ssl/server.key". For all supported SSL configuration
+# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
+#
+# We also recommend setting `force_ssl` in your endpoint, ensuring
+# no data is ever sent via http, always redirecting to https:
+#
+# config :dummy, DummyWeb.Endpoint,
+# force_ssl: [hsts: true]
+#
+# Check `Plug.SSL` for all available options in `force_ssl`.
+
+# Finally import the config/prod.secret.exs which loads secrets
+# and configuration from environment variables.
+import_config "prod.secret.exs"
diff --git a/dummy/config/prod.secret.exs b/dummy/config/prod.secret.exs
new file mode 100644
index 0000000..6a235e7
--- /dev/null
+++ b/dummy/config/prod.secret.exs
@@ -0,0 +1,41 @@
+# In this file, we load production configuration and secrets
+# from environment variables. You can also hardcode secrets,
+# although such is generally not recommended and you have to
+# remember to add this file to your .gitignore.
+use Mix.Config
+
+database_url =
+ System.get_env("DATABASE_URL") ||
+ raise """
+ environment variable DATABASE_URL is missing.
+ For example: ecto://USER:PASS@HOST/DATABASE
+ """
+
+config :dummy, Dummy.Repo,
+ # ssl: true,
+ url: database_url,
+ pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
+
+secret_key_base =
+ System.get_env("SECRET_KEY_BASE") ||
+ raise """
+ environment variable SECRET_KEY_BASE is missing.
+ You can generate one by calling: mix phx.gen.secret
+ """
+
+config :dummy, DummyWeb.Endpoint,
+ http: [
+ port: String.to_integer(System.get_env("PORT") || "4000"),
+ transport_options: [socket_opts: [:inet6]]
+ ],
+ secret_key_base: secret_key_base
+
+# ## Using releases (Elixir v1.9+)
+#
+# If you are doing OTP releases, you need to instruct Phoenix
+# to start each relevant endpoint:
+#
+# config :dummy, DummyWeb.Endpoint, server: true
+#
+# Then you can assemble a release by calling `mix release`.
+# See `mix help release` for more information.
diff --git a/dummy/config/test.exs b/dummy/config/test.exs
new file mode 100644
index 0000000..24c0254
--- /dev/null
+++ b/dummy/config/test.exs
@@ -0,0 +1,22 @@
+use Mix.Config
+
+# Configure your database
+#
+# The MIX_TEST_PARTITION environment variable can be used
+# to provide built-in test partitioning in CI environment.
+# Run `mix help test` for more information.
+config :dummy, Dummy.Repo,
+ username: "postgres",
+ password: "postgres",
+ database: "dummy_test#{System.get_env("MIX_TEST_PARTITION")}",
+ hostname: "localhost",
+ pool: Ecto.Adapters.SQL.Sandbox
+
+# We don't run a server during test. If one is required,
+# you can enable the server option below.
+config :dummy, DummyWeb.Endpoint,
+ http: [port: 4002],
+ server: false
+
+# Print only warnings and errors during test
+config :logger, level: :warn
diff --git a/dummy/lib/dummy.ex b/dummy/lib/dummy.ex
new file mode 100644
index 0000000..06b6320
--- /dev/null
+++ b/dummy/lib/dummy.ex
@@ -0,0 +1,9 @@
+defmodule Dummy do
+ @moduledoc """
+ Dummy keeps the contexts that define your domain
+ and business logic.
+
+ Contexts are also responsible for managing your data, regardless
+ if it comes from the database, an external API or others.
+ """
+end
diff --git a/dummy/lib/dummy/accounts.ex b/dummy/lib/dummy/accounts.ex
new file mode 100644
index 0000000..68cb7be
--- /dev/null
+++ b/dummy/lib/dummy/accounts.ex
@@ -0,0 +1,109 @@
+defmodule Dummy.Accounts do
+ @moduledoc """
+ The Accounts context.
+ """
+
+ import Ecto.Query, warn: false
+ alias Dummy.Repo
+
+ alias Dummy.Accounts.User
+
+ @doc """
+ Returns the list of users.
+
+ ## Examples
+
+ iex> list_users()
+ [%User{}, ...]
+
+ """
+ def list_users(params \\ %{}) do
+ Turbo.Ecto.turbo(User, params)
+ end
+
+ def list_users_2(params \\ %{}) do
+ queryable = from(u in User)
+ Turbo.Ecto.turbo(queryable, params)
+ end
+
+ @doc """
+ Gets a single user.
+
+ Raises `Ecto.NoResultsError` if the User does not exist.
+
+ ## Examples
+
+ iex> get_user!(123)
+ %User{}
+
+ iex> get_user!(456)
+ ** (Ecto.NoResultsError)
+
+ """
+ def get_user!(id), do: Repo.get!(User, id)
+
+ @doc """
+ Creates a user.
+
+ ## Examples
+
+ iex> create_user(%{field: value})
+ {:ok, %User{}}
+
+ iex> create_user(%{field: bad_value})
+ {:error, %Ecto.Changeset{}}
+
+ """
+ def create_user(attrs \\ %{}) do
+ %User{}
+ |> User.changeset(attrs)
+ |> Repo.insert()
+ end
+
+ @doc """
+ Updates a user.
+
+ ## Examples
+
+ iex> update_user(user, %{field: new_value})
+ {:ok, %User{}}
+
+ iex> update_user(user, %{field: bad_value})
+ {:error, %Ecto.Changeset{}}
+
+ """
+ def update_user(%User{} = user, attrs) do
+ user
+ |> User.changeset(attrs)
+ |> Repo.update()
+ end
+
+ @doc """
+ Deletes a user.
+
+ ## Examples
+
+ iex> delete_user(user)
+ {:ok, %User{}}
+
+ iex> delete_user(user)
+ {:error, %Ecto.Changeset{}}
+
+ """
+ def delete_user(%User{} = user) do
+ Repo.delete(user)
+ end
+
+ @doc """
+ Returns an `%Ecto.Changeset{}` for tracking user changes.
+
+ ## Examples
+
+ iex> change_user(user)
+ %Ecto.Changeset{data: %User{}}
+
+ """
+ def change_user(%User{} = user, attrs \\ %{}) do
+ User.changeset(user, attrs)
+ end
+end
diff --git a/dummy/lib/dummy/accounts/user.ex b/dummy/lib/dummy/accounts/user.ex
new file mode 100644
index 0000000..9d0baed
--- /dev/null
+++ b/dummy/lib/dummy/accounts/user.ex
@@ -0,0 +1,19 @@
+defmodule Dummy.Accounts.User do
+ use Ecto.Schema
+ import Ecto.Changeset
+
+ schema "users" do
+ field :email, :string
+ field :mobile, :string
+ field :nickname, :string
+
+ timestamps()
+ end
+
+ @doc false
+ def changeset(user, attrs) do
+ user
+ |> cast(attrs, [:nickname, :mobile, :email])
+ |> validate_required([:nickname, :mobile, :email])
+ end
+end
diff --git a/dummy/lib/dummy/application.ex b/dummy/lib/dummy/application.ex
new file mode 100644
index 0000000..fa02eeb
--- /dev/null
+++ b/dummy/lib/dummy/application.ex
@@ -0,0 +1,34 @@
+defmodule Dummy.Application do
+ # See https://hexdocs.pm/elixir/Application.html
+ # for more information on OTP Applications
+ @moduledoc false
+
+ use Application
+
+ def start(_type, _args) do
+ children = [
+ # Start the Ecto repository
+ Dummy.Repo,
+ # Start the Telemetry supervisor
+ DummyWeb.Telemetry,
+ # Start the PubSub system
+ {Phoenix.PubSub, name: Dummy.PubSub},
+ # Start the Endpoint (http/https)
+ DummyWeb.Endpoint
+ # Start a worker by calling: Dummy.Worker.start_link(arg)
+ # {Dummy.Worker, arg}
+ ]
+
+ # See https://hexdocs.pm/elixir/Supervisor.html
+ # for other strategies and supported options
+ opts = [strategy: :one_for_one, name: Dummy.Supervisor]
+ Supervisor.start_link(children, opts)
+ end
+
+ # Tell Phoenix to update the endpoint configuration
+ # whenever the application is updated.
+ def config_change(changed, _new, removed) do
+ DummyWeb.Endpoint.config_change(changed, removed)
+ :ok
+ end
+end
diff --git a/dummy/lib/dummy/repo.ex b/dummy/lib/dummy/repo.ex
new file mode 100644
index 0000000..d980f4b
--- /dev/null
+++ b/dummy/lib/dummy/repo.ex
@@ -0,0 +1,20 @@
+defmodule Dummy.Repo do
+ use Ecto.Repo,
+ otp_app: :dummy,
+ adapter: Ecto.Adapters.Postgres
+
+ @doc """
+ Returns the pagi data list.
+
+ ## Examples
+
+ iex> Scrm.Turbo.find_all(Staff, %{})
+ %{entries: [], paginate: %{ current_page: 1, next_page: nil, per_page: 10, prev_page: nil, total_count: 0, total_pages: 0 } }
+
+ """
+ @spec find_all(Ecto.Schema.t() | Ecto.Queryable.t(), map(), keyword()) :: Map.t()
+ def find_all(queryable, params \\ %{}, opts \\ []) do
+ queryable
+ |> Turbo.Ecto.turbo(params, opts)
+ end
+end
diff --git a/dummy/lib/dummy_web.ex b/dummy/lib/dummy_web.ex
new file mode 100644
index 0000000..8ae2b43
--- /dev/null
+++ b/dummy/lib/dummy_web.ex
@@ -0,0 +1,102 @@
+defmodule DummyWeb do
+ @moduledoc """
+ The entrypoint for defining your web interface, such
+ as controllers, views, channels and so on.
+
+ This can be used in your application as:
+
+ use DummyWeb, :controller
+ use DummyWeb, :view
+
+ The definitions below will be executed for every view,
+ controller, etc, so keep them short and clean, focused
+ on imports, uses and aliases.
+
+ Do NOT define functions inside the quoted expressions
+ below. Instead, define any helper function in modules
+ and import those modules here.
+ """
+
+ def controller do
+ quote do
+ use Phoenix.Controller, namespace: DummyWeb
+
+ import Plug.Conn
+ import DummyWeb.Gettext
+ alias DummyWeb.Router.Helpers, as: Routes
+ end
+ end
+
+ def view do
+ quote do
+ use Phoenix.View,
+ root: "lib/dummy_web/templates",
+ namespace: DummyWeb
+
+ # Import convenience functions from controllers
+ import Phoenix.Controller,
+ only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
+
+ # Include shared imports and aliases for views
+ unquote(view_helpers())
+ end
+ end
+
+ def live_view do
+ quote do
+ use Phoenix.LiveView,
+ layout: {DummyWeb.LayoutView, "live.html"}
+
+ unquote(view_helpers())
+ end
+ end
+
+ def live_component do
+ quote do
+ use Phoenix.LiveComponent
+
+ unquote(view_helpers())
+ end
+ end
+
+ def router do
+ quote do
+ use Phoenix.Router
+
+ import Plug.Conn
+ import Phoenix.Controller
+ import Phoenix.LiveView.Router
+ end
+ end
+
+ def channel do
+ quote do
+ use Phoenix.Channel
+ import DummyWeb.Gettext
+ end
+ end
+
+ defp view_helpers do
+ quote do
+ # Use all HTML functionality (forms, tags, etc)
+ use Phoenix.HTML
+
+ # Import LiveView helpers (live_render, live_component, live_patch, etc)
+ import Phoenix.LiveView.Helpers
+
+ # Import basic rendering functionality (render, render_layout, etc)
+ import Phoenix.View
+
+ import DummyWeb.ErrorHelpers
+ import DummyWeb.Gettext
+ alias DummyWeb.Router.Helpers, as: Routes
+ end
+ end
+
+ @doc """
+ When used, dispatch to the appropriate controller/view/etc.
+ """
+ defmacro __using__(which) when is_atom(which) do
+ apply(__MODULE__, which, [])
+ end
+end
diff --git a/dummy/lib/dummy_web/channels/user_socket.ex b/dummy/lib/dummy_web/channels/user_socket.ex
new file mode 100644
index 0000000..564ca05
--- /dev/null
+++ b/dummy/lib/dummy_web/channels/user_socket.ex
@@ -0,0 +1,35 @@
+defmodule DummyWeb.UserSocket do
+ use Phoenix.Socket
+
+ ## Channels
+ # channel "room:*", DummyWeb.RoomChannel
+
+ # Socket params are passed from the client and can
+ # be used to verify and authenticate a user. After
+ # verification, you can put default assigns into
+ # the socket that will be set for all channels, ie
+ #
+ # {:ok, assign(socket, :user_id, verified_user_id)}
+ #
+ # To deny connection, return `:error`.
+ #
+ # See `Phoenix.Token` documentation for examples in
+ # performing token verification on connect.
+ @impl true
+ def connect(_params, socket, _connect_info) do
+ {:ok, socket}
+ end
+
+ # Socket id's are topics that allow you to identify all sockets for a given user:
+ #
+ # def id(socket), do: "user_socket:#{socket.assigns.user_id}"
+ #
+ # Would allow you to broadcast a "disconnect" event and terminate
+ # all active sockets and channels for a given user:
+ #
+ # DummyWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
+ #
+ # Returning `nil` makes this socket anonymous.
+ @impl true
+ def id(_socket), do: nil
+end
diff --git a/dummy/lib/dummy_web/controllers/user_controller.ex b/dummy/lib/dummy_web/controllers/user_controller.ex
new file mode 100644
index 0000000..6b29417
--- /dev/null
+++ b/dummy/lib/dummy_web/controllers/user_controller.ex
@@ -0,0 +1,63 @@
+defmodule DummyWeb.UserController do
+ use DummyWeb, :controller
+
+ alias Dummy.Accounts
+ alias Dummy.Accounts.User
+
+ def index(conn, params) do
+ with %{entries: entries, paginate: paginate} <- Accounts.list_users(params) do
+ render(conn, "index.html", users: entries)
+ end
+ end
+
+ def new(conn, _params) do
+ changeset = Accounts.change_user(%User{})
+ render(conn, "new.html", changeset: changeset)
+ end
+
+ def create(conn, %{"user" => user_params}) do
+ case Accounts.create_user(user_params) do
+ {:ok, user} ->
+ conn
+ |> put_flash(:info, "User created successfully.")
+ |> redirect(to: Routes.user_path(conn, :show, user))
+
+ {:error, %Ecto.Changeset{} = changeset} ->
+ render(conn, "new.html", changeset: changeset)
+ end
+ end
+
+ def show(conn, %{"id" => id}) do
+ user = Accounts.get_user!(id)
+ render(conn, "show.html", user: user)
+ end
+
+ def edit(conn, %{"id" => id}) do
+ user = Accounts.get_user!(id)
+ changeset = Accounts.change_user(user)
+ render(conn, "edit.html", user: user, changeset: changeset)
+ end
+
+ def update(conn, %{"id" => id, "user" => user_params}) do
+ user = Accounts.get_user!(id)
+
+ case Accounts.update_user(user, user_params) do
+ {:ok, user} ->
+ conn
+ |> put_flash(:info, "User updated successfully.")
+ |> redirect(to: Routes.user_path(conn, :show, user))
+
+ {:error, %Ecto.Changeset{} = changeset} ->
+ render(conn, "edit.html", user: user, changeset: changeset)
+ end
+ end
+
+ def delete(conn, %{"id" => id}) do
+ user = Accounts.get_user!(id)
+ {:ok, _user} = Accounts.delete_user(user)
+
+ conn
+ |> put_flash(:info, "User deleted successfully.")
+ |> redirect(to: Routes.user_path(conn, :index))
+ end
+end
diff --git a/dummy/lib/dummy_web/endpoint.ex b/dummy/lib/dummy_web/endpoint.ex
new file mode 100644
index 0000000..453200a
--- /dev/null
+++ b/dummy/lib/dummy_web/endpoint.ex
@@ -0,0 +1,54 @@
+defmodule DummyWeb.Endpoint do
+ use Phoenix.Endpoint, otp_app: :dummy
+
+ # The session will be stored in the cookie and signed,
+ # this means its contents can be read but not tampered with.
+ # Set :encryption_salt if you would also like to encrypt it.
+ @session_options [
+ store: :cookie,
+ key: "_dummy_key",
+ signing_salt: "kvJwUSxL"
+ ]
+
+ socket "/socket", DummyWeb.UserSocket,
+ websocket: true,
+ longpoll: false
+
+ socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
+
+ # Serve at "/" the static files from "priv/static" directory.
+ #
+ # You should set gzip to true if you are running phx.digest
+ # when deploying your static files in production.
+ plug Plug.Static,
+ at: "/",
+ from: :dummy,
+ gzip: false,
+ only: ~w(css fonts images js favicon.ico robots.txt)
+
+ # Code reloading can be explicitly enabled under the
+ # :code_reloader configuration of your endpoint.
+ if code_reloading? do
+ socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
+ plug Phoenix.LiveReloader
+ plug Phoenix.CodeReloader
+ plug Phoenix.Ecto.CheckRepoStatus, otp_app: :dummy
+ end
+
+ plug Phoenix.LiveDashboard.RequestLogger,
+ param_key: "request_logger",
+ cookie_key: "request_logger"
+
+ plug Plug.RequestId
+ plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
+
+ plug Plug.Parsers,
+ parsers: [:urlencoded, :multipart, :json],
+ pass: ["*/*"],
+ json_decoder: Phoenix.json_library()
+
+ plug Plug.MethodOverride
+ plug Plug.Head
+ plug Plug.Session, @session_options
+ plug DummyWeb.Router
+end
diff --git a/dummy/lib/dummy_web/gettext.ex b/dummy/lib/dummy_web/gettext.ex
new file mode 100644
index 0000000..0c405b5
--- /dev/null
+++ b/dummy/lib/dummy_web/gettext.ex
@@ -0,0 +1,24 @@
+defmodule DummyWeb.Gettext do
+ @moduledoc """
+ A module providing Internationalization with a gettext-based API.
+
+ By using [Gettext](https://hexdocs.pm/gettext),
+ your module gains a set of macros for translations, for example:
+
+ import DummyWeb.Gettext
+
+ # Simple translation
+ gettext("Here is the string to translate")
+
+ # Plural translation
+ ngettext("Here is the string to translate",
+ "Here are the strings to translate",
+ 3)
+
+ # Domain-based translation
+ dgettext("errors", "Here is the error message to translate")
+
+ See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
+ """
+ use Gettext, otp_app: :dummy
+end
diff --git a/dummy/lib/dummy_web/live/page_live.ex b/dummy/lib/dummy_web/live/page_live.ex
new file mode 100644
index 0000000..c498e7f
--- /dev/null
+++ b/dummy/lib/dummy_web/live/page_live.ex
@@ -0,0 +1,39 @@
+defmodule DummyWeb.PageLive do
+ use DummyWeb, :live_view
+
+ @impl true
+ def mount(_params, _session, socket) do
+ {:ok, assign(socket, query: "", results: %{})}
+ end
+
+ @impl true
+ def handle_event("suggest", %{"q" => query}, socket) do
+ {:noreply, assign(socket, results: search(query), query: query)}
+ end
+
+ @impl true
+ def handle_event("search", %{"q" => query}, socket) do
+ case search(query) do
+ %{^query => vsn} ->
+ {:noreply, redirect(socket, external: "https://hexdocs.pm/#{query}/#{vsn}")}
+
+ _ ->
+ {:noreply,
+ socket
+ |> put_flash(:error, "No dependencies found matching \"#{query}\"")
+ |> assign(results: %{}, query: query)}
+ end
+ end
+
+ defp search(query) do
+ if not DummyWeb.Endpoint.config(:code_reloader) do
+ raise "action disabled when not in development"
+ end
+
+ for {app, desc, vsn} <- Application.started_applications(),
+ app = to_string(app),
+ String.starts_with?(app, query) and not List.starts_with?(desc, ~c"ERTS"),
+ into: %{},
+ do: {app, vsn}
+ end
+end
diff --git a/dummy/lib/dummy_web/live/page_live.html.leex b/dummy/lib/dummy_web/live/page_live.html.leex
new file mode 100644
index 0000000..52509c2
--- /dev/null
+++ b/dummy/lib/dummy_web/live/page_live.html.leex
@@ -0,0 +1,48 @@
+ Peace of mind from prototype to production <%= get_flash(@conn, :info) %> <%= get_flash(@conn, :error) %> <%= live_flash(@flash, :info) %> <%= live_flash(@flash, :error) %><%= gettext "Welcome to %{name}!", name: "Phoenix" %>
+ Resources
+
+
+ Help
+
+
+
Oops, something went wrong! Please check the errors below.
+| Nickname | +Mobile | ++ | |
|---|---|---|---|
| <%= user.nickname %> | +<%= user.mobile %> | +<%= user.email %> | + ++ <%= link "Show", to: Routes.user_path(@conn, :show, user) %> + <%= link "Edit", to: Routes.user_path(@conn, :edit, user) %> + <%= link "Delete", to: Routes.user_path(@conn, :delete, user), method: :delete, data: [confirm: "Are you sure?"] %> + | +