Skip to content

Commit 7927638

Browse files
Merge branch 'main' into sf/error-pages
2 parents d5dbaf0 + c1a317b commit 7927638

40 files changed

+519
-104
lines changed

.env.stg.sample

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
DATABASE_URL=ecto://<USER>:<PASSWORD>@db:<PORT>/cesium.link_stg
2-
GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>
3-
GOOGLE_CLIENT_SECRET=<GOOGLE_CLIENT_SECRET>
1+
export DATABASE_URL=ecto://<USER>:<PASSWORD>@db:<PORT>/cesium.link_stg
2+
export GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>
3+
export GOOGLE_CLIENT_SECRET=<GOOGLE_CLIENT_SECRET>

.formatter.exs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"*.{heex,ex,exs}",
77
"priv/*/seeds.exs",
88
"priv/repo/seeds/*.exs",
9-
"{config,lib,test}/**/*.{heex,ex,exs}",
10-
"storybook/**/*.exs"
9+
"{config,lib,test}/**/*.{heex,ex,exs}"
1110
],
1211
subdirectories: ["priv/*/migrations"]
1312
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Feature Request
2+
description: Suggest an idea for this project.
3+
labels: ["enhancement"]
4+
body:
5+
- type: checkboxes
6+
attributes:
7+
label: Check for existing issues
8+
description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it.
9+
options:
10+
- label: Completed
11+
required: true
12+
- type: textarea
13+
attributes:
14+
label: Describe the feature
15+
description: A clear and concise description of what you want to happen.
16+
validations:
17+
required: true
18+
- type: textarea
19+
attributes:
20+
label: |
21+
If applicable, add mockups / screenshots to help present your vision of the feature
22+
description: Drag images into the text input below.
23+
validations:
24+
required: false
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Bug Report
2+
description: Create a bug report to help us improve.
3+
labels: ["bug"]
4+
body:
5+
- type: checkboxes
6+
attributes:
7+
label: Check for existing issues
8+
description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it.
9+
options:
10+
- label: Completed
11+
required: true
12+
- type: textarea
13+
attributes:
14+
label: Describe the bug / provide steps to reproduce it
15+
description: A clear and concise description of what the bug is.
16+
validations:
17+
required: true
18+
- type: dropdown
19+
id: browsers
20+
attributes:
21+
label: What browsers are you seeing the problem on?
22+
multiple: true
23+
options:
24+
- Firefox
25+
- Chrome
26+
- Safari
27+
- Microsoft Edge
28+
- type: textarea
29+
attributes:
30+
label: If applicable, add screenshots to help explain present your vision of the bug
31+
description: Drag issues into the text input below.
32+
validations:
33+
required: false

.github/workflows/style.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
branches: [main]
66
types: [opened, synchronize]
7+
paths:
8+
- '**/*.ex'
9+
- '**/*.exs'
10+
- '**/*.html.heex'
711

812
jobs:
913
style:

.github/workflows/test.yml

+8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ name: Build and Test
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- '**/*.ex'
8+
- '**/*.exs'
9+
- '**/*.html.heex'
610
pull_request:
711
branches: [main]
812
types: [opened, synchronize]
13+
paths:
14+
- '**/*.ex'
15+
- '**/*.exs'
16+
- '**/*.html.heex'
917

1018
jobs:
1119
build:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.env
22
.env.*
33
!.env.*.sample
4+
.envrc
45

56
# The directory Mix will write compiled artifacts to.
67
/_build/

Dockerfile.dev

-16
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@ FROM elixir:1.14-alpine
33
# Install build dependencies
44
RUN apk add --no-cache build-base git python3
55

6-
# Install pdf generation dependencies
7-
RUN apk add --no-cache \
8-
libstdc++ \
9-
libx11 \
10-
libxrender \
11-
libxext \
12-
libssl3 \
13-
ca-certificates \
14-
fontconfig \
15-
freetype \
16-
ttf-droid \
17-
ttf-freefont \
18-
ttf-liberation \
19-
# more fonts
20-
;
21-
226
# Install hex + rebar
237
RUN mix local.hex --force && \
248
mix local.rebar --force

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ We have a [Contributing Guide][contributing] to help you getting started.
3232
<img src=".github/brand/cesium-DARK.svg#gh-light-mode-only" width="300">
3333
<img src=".github/brand/cesium-LIGHT.svg#gh-dark-mode-only" width="300">
3434

35-
Copyright (c) 2020, CeSIUM.
35+
Copyright (c) 2024, CeSIUM.
3636

3737
This project is licensed under the MIT License - see the [LICENSE][license]
3838
file for details.

assets/js/hooks/emoji.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export const EmojiPicker = {
44
mounted() {
55
this.el.addEventListener("click", (event) =>
66
{
7-
if(this.el.parentElement.querySelector("em-emoji-picker") == null) {
8-
const picker = new EmojiMart.Picker({onEmojiSelect: (data) => {updateEmojiInput(this.el.id, data.id); }, theme: "light", set: "native", autoFocus: true, onClickOutside: () => {picker.remove();}});
7+
if (this.el.parentElement.querySelector("em-emoji-picker") == null) {
8+
const picker = new EmojiMart.Picker({onEmojiSelect: (data) => {updateEmojiInput(this.el.id, data.id); }, theme: "light", set: "native", autoFocus: true, onClickOutside: () => {picker.remove()}});
99
picker.style.position = "absolute";
1010
picker.style.left = "100px";
1111
this.el.parentElement.appendChild(picker);

bin/deploy

+2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ function display_help() {
1919
cat <<EOF
2020
$(help_title_section Usage)
2121
${PROGRAM} [options] <command>
22+
2223
$(help_title_section Commands)
2324
prod Deploy to production environment.
2425
stg Deploy to staging environment [default command].
26+
2527
$(help_title_section Options)
2628
-h --help Show this screen.
2729
-v --version Show version.

config/prod.exs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Config
66
# which you should run after static files are built and
77
# before starting your production server.
88
config :cesium_link, CesiumLinkWeb.Endpoint,
9+
url: [scheme: "https", host: "cesium.link", port: 443],
10+
force_ssl: [rewrite_on: [:x_forwarded_proto]],
911
cache_static_manifest: "priv/static/cache_manifest.json"
1012

1113
# Do not print debug messages in production

config/runtime.exs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ if config_env() in [:prod, :stg] do
3131
%URI{host: database_host} = URI.parse(database_url)
3232

3333
# Location of root certificates to verify database SSL connections
34-
3534
database_ca_cert_filepath =
3635
System.get_env("DATABASE_CA_CERT_FILEPATH") || "/etc/ssl/certs/ca-certificates.crt"
3736

config/test.exs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Config
22

3-
# Only in tests, remove the complexity from the password hashing algorithm
4-
config :bcrypt_elixir, :log_rounds, 1
5-
63
# Configure your database
74
#
85
# The MIX_TEST_PARTITION environment variable can be used

docker-compose.dev.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3"
33
services:
44
db:
55
image: postgres:14.1
6-
container_name: atomic_db
6+
container_name: cesium_link_db
77
env_file: .env.dev
88
environment:
99
POSTGRES_USER: ${DB_USERNAME:-postgres}
@@ -12,7 +12,7 @@ services:
1212
volumes:
1313
- /var/lib/postgresql/data
1414
web:
15-
container_name: atomic_web
15+
container_name: cesium_link_web
1616
env_file: .env.dev
1717
environment:
1818
MIX_ENV: ${MIX_ENV:-dev}

fly-prod.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
app = "cesium-link-prod"
2+
primary_region = "mad"
3+
kill_signal = "SIGTERM"
4+
5+
[deploy]
6+
release_command = "/app/bin/migrate"
7+
8+
[env]
9+
MIX_ENV = "prod"
10+
PHX_HOST = "cesium.link"
11+
PORT = "8080"
12+
13+
[http_service]
14+
internal_port = 8080
15+
force_https = true
16+
auto_stop_machines = false
17+
auto_start_machines = true
18+
min_machines_running = 0
19+
processes = ["app"]
20+
21+
[http_service.concurrency]
22+
type = "connections"
23+
hard_limit = 1000
24+
soft_limit = 1000
25+
26+
[[vm]]
27+
memory = "512mb"
28+
cpu_kind = "shared"
29+
cpus = 1

fly-stg.toml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ app = "cesium-link-stg"
22
primary_region = "mad"
33
kill_signal = "SIGTERM"
44

5-
[build]
6-
75
[deploy]
86
release_command = "/app/bin/migrate"
97

lib/cesium_link/links/link.ex

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ defmodule CesiumLink.Links.Link do
22
@moduledoc """
33
Link schema.
44
"""
5-
use Ecto.Schema
6-
import Ecto.Changeset
5+
use CesiumLink.Schema
76

87
@required_fields ~w(name emoji url attention edited_at)a
98
@optional_fields ~w(index archived visits)a
109

11-
@primary_key {:id, :binary_id, autogenerate: true}
12-
@foreign_key_type :binary_id
1310
schema "links" do
1411
field :archived, :boolean, default: false
1512
field :attention, :boolean, default: false
@@ -29,6 +26,6 @@ defmodule CesiumLink.Links.Link do
2926
|> cast(attrs, @required_fields ++ @optional_fields)
3027
|> unique_constraint(:index)
3128
|> validate_required(@required_fields)
32-
|> validate_format(:url, ~r{^https?://}, message: "must start with http:// or https://")
29+
|> validate_url(:url)
3330
end
3431
end

lib/cesium_link/redirects/redirect.ex

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ defmodule CesiumLink.Redirects.Redirect do
22
@moduledoc """
33
Redirect schema.
44
"""
5-
use Ecto.Schema
6-
import Ecto.Changeset
5+
use CesiumLink.Schema
76

87
@required_fields ~w(name slug url type edited_at)a
98
@optional_fields ~w(visits)a
109

11-
@primary_key {:id, :binary_id, autogenerate: true}
12-
@foreign_key_type :binary_id
1310
schema "redirects" do
1411
field :name, :string
1512
field :slug, :string
@@ -26,9 +23,10 @@ defmodule CesiumLink.Redirects.Redirect do
2623
redirect
2724
|> cast(attrs, @required_fields ++ @optional_fields)
2825
|> validate_required(@required_fields)
29-
|> validate_format(:url, ~r{^https?://}, message: "must start with http:// or https://")
26+
|> validate_url(:url)
3027
|> validate_format(:slug, ~r{^[a-z0-9-]+$},
3128
message: "must contain only lowercase letters, numbers, and hyphens"
3229
)
30+
|> unique_constraint([:slug, :type], message: "already in use")
3331
end
3432
end

lib/cesium_link/schema.ex

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
defmodule CesiumLink.Schema do
2+
@moduledoc """
3+
The application Schema for all the modules, providing Ecto.UUIDs as default
4+
id.
5+
"""
6+
import Ecto.Changeset
7+
8+
defmacro __using__(_) do
9+
quote do
10+
use Ecto.Schema
11+
import Ecto.Changeset
12+
13+
@primary_key {:id, :binary_id, autogenerate: true}
14+
@foreign_key_type :binary_id
15+
16+
def validate_url(changeset, field) do
17+
changeset
18+
|> validate_format(
19+
:url,
20+
~r/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/,
21+
message: "must start with http:// or https:// and have a valid domain"
22+
)
23+
end
24+
end
25+
end
26+
end

lib/cesium_link_web/components/core_components.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ defmodule CesiumLinkWeb.CoreComponents do
443443
end
444444

445445
~H"""
446-
<div class="overflow-y-auto px-4 sm:overflow-visible sm:px-0">
446+
<div class="overflow-x-auto overflow-y-hidden px-4 sm:overflow-visible sm:px-0">
447447
<table class="w-[40rem] mt-11 sm:w-full">
448448
<thead class="text-left text-sm leading-6 text-zinc-500">
449449
<tr>

0 commit comments

Comments
 (0)