Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deps #146 #147

Merged
merged 14 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: elixir
elixir:
- 1.10.4
- 1.12.3
otp_release:
- 23.0.3
- 24.0.2
services:
- postgresql
env:
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: mix phx.server
5 changes: 0 additions & 5 deletions assets/.babelrc

This file was deleted.

53 changes: 40 additions & 13 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
// 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 from '../css/app.css';
// We import the CSS which is extracted to its own file by esbuild.
// Remove this line if you add a your own CSS build pipeline (e.g postcss).
import "../css/app.css"

// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
// in "webpack.config.js".
// If you want to use Phoenix channels, run `mix help phx.gen.channel`
// to get started and then uncomment the line below.
// import "./user_socket.js"

// You can include dependencies in two ways.
//
// Import dependencies
// The simplest option is to put them in assets/vendor and
// import them using relative paths:
//
import 'phoenix_html';

// Import local files
// import "./vendor/some-package.js"
//
// Alternatively, you can `npm install some-package` and import
// them using a path starting with the package name:
//
// Local files can be imported directly using relative paths, for example:
// import socket from "./socket"
// import "some-package"
//

// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
import "phoenix_html"
// Establish Phoenix Socket and LiveView configuration.
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
import topbar from "../vendor/topbar"

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
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", info => topbar.show())
window.addEventListener("phx:page-loading-stop", info => topbar.hide())

// 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
24 changes: 0 additions & 24 deletions assets/package.json

This file was deleted.

157 changes: 157 additions & 0 deletions assets/vendor/topbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/**
* @license MIT
* topbar 1.0.0, 2021-01-06
* http://buunguyen.github.io/topbar
* Copyright (c) 2021 Buu Nguyen
*/
(function (window, document) {
"use strict";

// https://gist.github.com/paulirish/1579671
(function () {
var lastTime = 0;
var vendors = ["ms", "moz", "webkit", "o"];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame =
window[vendors[x] + "RequestAnimationFrame"];
window.cancelAnimationFrame =
window[vendors[x] + "CancelAnimationFrame"] ||
window[vendors[x] + "CancelRequestAnimationFrame"];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function (callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
})();

var canvas,
progressTimerId,
fadeTimerId,
currentProgress,
showing,
addEvent = function (elem, type, handler) {
if (elem.addEventListener) elem.addEventListener(type, handler, false);
else if (elem.attachEvent) elem.attachEvent("on" + type, handler);
else elem["on" + type] = handler;
},
options = {
autoRun: true,
barThickness: 3,
barColors: {
0: "rgba(26, 188, 156, .9)",
".25": "rgba(52, 152, 219, .9)",
".50": "rgba(241, 196, 15, .9)",
".75": "rgba(230, 126, 34, .9)",
"1.0": "rgba(211, 84, 0, .9)",
},
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, .6)",
className: null,
},
repaint = function () {
canvas.width = window.innerWidth;
canvas.height = options.barThickness * 5; // need space for shadow

var ctx = canvas.getContext("2d");
ctx.shadowBlur = options.shadowBlur;
ctx.shadowColor = options.shadowColor;

var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
for (var stop in options.barColors)
lineGradient.addColorStop(stop, options.barColors[stop]);
ctx.lineWidth = options.barThickness;
ctx.beginPath();
ctx.moveTo(0, options.barThickness / 2);
ctx.lineTo(
Math.ceil(currentProgress * canvas.width),
options.barThickness / 2
);
ctx.strokeStyle = lineGradient;
ctx.stroke();
},
createCanvas = function () {
canvas = document.createElement("canvas");
var style = canvas.style;
style.position = "fixed";
style.top = style.left = style.right = style.margin = style.padding = 0;
style.zIndex = 100001;
style.display = "none";
if (options.className) canvas.classList.add(options.className);
document.body.appendChild(canvas);
addEvent(window, "resize", repaint);
},
topbar = {
config: function (opts) {
for (var key in opts)
if (options.hasOwnProperty(key)) options[key] = opts[key];
},
show: function () {
if (showing) return;
showing = true;
if (fadeTimerId !== null) window.cancelAnimationFrame(fadeTimerId);
if (!canvas) createCanvas();
canvas.style.opacity = 1;
canvas.style.display = "block";
topbar.progress(0);
if (options.autoRun) {
(function loop() {
progressTimerId = window.requestAnimationFrame(loop);
topbar.progress(
"+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
);
})();
}
},
progress: function (to) {
if (typeof to === "undefined") return currentProgress;
if (typeof to === "string") {
to =
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0
? currentProgress
: 0) + parseFloat(to);
}
currentProgress = to > 1 ? 1 : to;
repaint();
return currentProgress;
},
hide: function () {
if (!showing) return;
showing = false;
if (progressTimerId != null) {
window.cancelAnimationFrame(progressTimerId);
progressTimerId = null;
}
(function loop() {
if (topbar.progress("+.1") >= 1) {
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
canvas.style.opacity -= 0.05;
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
if (canvas.style.opacity <= 0.05) {
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
canvas.style.display = "none";
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
fadeTimerId = null;
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
return;
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
}
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
}
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
fadeTimerId = window.requestAnimationFrame(loop);
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
})();
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
},
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
};
nelsonic marked this conversation as resolved.
Show resolved Hide resolved

if (typeof module === "object" && typeof module.exports === "object") {
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
module.exports = topbar;
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
} else if (typeof define === "function" && define.amd) {
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
define(function () {
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
return topbar;
});
} else {
this.topbar = topbar;
}
}.call(this, window, document));
43 changes: 0 additions & 43 deletions assets/webpack.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ config :joken, default_signer: System.get_env("SECRET_KEY_BASE")
# 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"

# https://gist.github.com/chrismccord/2ab350f154235ad4a4d0f4de6decba7b
# Configure esbuild (the version is required)
config :esbuild,
version: "0.12.18",
default: [
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
12 changes: 3 additions & 9 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ config :auth, AuthWeb.Endpoint,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
]
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}
]

# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
Expand Down Expand Up @@ -73,4 +67,4 @@ config :logger, :console, format: "[$level] $message\n"
config :phoenix, :stacktrace_depth, 20

# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime
config :phoenix, :plug_init_mode, :runtime
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config :auth, Auth.Repo,
# you can enable the server option below.
config :auth, AuthWeb.Endpoint,
http: [port: 4002],
server: false
server: true # https://elixirforum.com/t/wallaby-with-phoenix-1-16-rc0/42352/9

# Print only warnings and errors during test
config :logger, level: :warn
10 changes: 7 additions & 3 deletions elixir_buildpack.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Elixir version
elixir_version=1.10.4
elixir_version=1.12.3

# Erlang version
# available versions https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions
erlang_version=23.0.3
erlang_version=23.3.2

# always_rebuild=true
always_rebuild=true

# Invoke assets.deploy defined in your mix.exs to deploy assets with esbuild
# Note we nuke the esbuild executable from the image
hook_post_compile="eval mix assets.deploy && rm -f _build/esbuild"
Loading