Skip to content

Commit

Permalink
Merge branch 'main' into sf/error-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Sep 16, 2024
2 parents d5dbaf0 + c1a317b commit 7927638
Show file tree
Hide file tree
Showing 40 changed files with 519 additions and 104 deletions.
6 changes: 3 additions & 3 deletions .env.stg.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DATABASE_URL=ecto://<USER>:<PASSWORD>@db:<PORT>/cesium.link_stg
GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>
GOOGLE_CLIENT_SECRET=<GOOGLE_CLIENT_SECRET>
export DATABASE_URL=ecto://<USER>:<PASSWORD>@db:<PORT>/cesium.link_stg
export GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>
export GOOGLE_CLIENT_SECRET=<GOOGLE_CLIENT_SECRET>
3 changes: 1 addition & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"*.{heex,ex,exs}",
"priv/*/seeds.exs",
"priv/repo/seeds/*.exs",
"{config,lib,test}/**/*.{heex,ex,exs}",
"storybook/**/*.exs"
"{config,lib,test}/**/*.{heex,ex,exs}"
],
subdirectories: ["priv/*/migrations"]
]
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/0-feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Feature Request
description: Suggest an idea for this project.
labels: ["enhancement"]
body:
- type: checkboxes
attributes:
label: Check for existing issues
description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it.
options:
- label: Completed
required: true
- type: textarea
attributes:
label: Describe the feature
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: |
If applicable, add mockups / screenshots to help present your vision of the feature
description: Drag images into the text input below.
validations:
required: false
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Bug Report
description: Create a bug report to help us improve.
labels: ["bug"]
body:
- type: checkboxes
attributes:
label: Check for existing issues
description: Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a `+1` (👍) on it.
options:
- label: Completed
required: true
- type: textarea
attributes:
label: Describe the bug / provide steps to reproduce it
description: A clear and concise description of what the bug is.
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: What browsers are you seeing the problem on?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- type: textarea
attributes:
label: If applicable, add screenshots to help explain present your vision of the bug
description: Drag issues into the text input below.
validations:
required: false
4 changes: 4 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
branches: [main]
types: [opened, synchronize]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'

jobs:
style:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ name: Build and Test
on:
push:
branches: [main]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'
pull_request:
branches: [main]
types: [opened, synchronize]
paths:
- '**/*.ex'
- '**/*.exs'
- '**/*.html.heex'

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.env
.env.*
!.env.*.sample
.envrc

# The directory Mix will write compiled artifacts to.
/_build/
Expand Down
16 changes: 0 additions & 16 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ FROM elixir:1.14-alpine
# Install build dependencies
RUN apk add --no-cache build-base git python3

# Install pdf generation dependencies
RUN apk add --no-cache \
libstdc++ \
libx11 \
libxrender \
libxext \
libssl3 \
ca-certificates \
fontconfig \
freetype \
ttf-droid \
ttf-freefont \
ttf-liberation \
# more fonts
;

# Install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ We have a [Contributing Guide][contributing] to help you getting started.
<img src=".github/brand/cesium-DARK.svg#gh-light-mode-only" width="300">
<img src=".github/brand/cesium-LIGHT.svg#gh-dark-mode-only" width="300">

Copyright (c) 2020, CeSIUM.
Copyright (c) 2024, CeSIUM.

This project is licensed under the MIT License - see the [LICENSE][license]
file for details.
4 changes: 2 additions & 2 deletions assets/js/hooks/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const EmojiPicker = {
mounted() {
this.el.addEventListener("click", (event) =>
{
if(this.el.parentElement.querySelector("em-emoji-picker") == null) {
const picker = new EmojiMart.Picker({onEmojiSelect: (data) => {updateEmojiInput(this.el.id, data.id); }, theme: "light", set: "native", autoFocus: true, onClickOutside: () => {picker.remove();}});
if (this.el.parentElement.querySelector("em-emoji-picker") == null) {
const picker = new EmojiMart.Picker({onEmojiSelect: (data) => {updateEmojiInput(this.el.id, data.id); }, theme: "light", set: "native", autoFocus: true, onClickOutside: () => {picker.remove()}});
picker.style.position = "absolute";
picker.style.left = "100px";
this.el.parentElement.appendChild(picker);
Expand Down
2 changes: 2 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ function display_help() {
cat <<EOF
$(help_title_section Usage)
${PROGRAM} [options] <command>
$(help_title_section Commands)
prod Deploy to production environment.
stg Deploy to staging environment [default command].
$(help_title_section Options)
-h --help Show this screen.
-v --version Show version.
Expand Down
2 changes: 2 additions & 0 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Config
# which you should run after static files are built and
# before starting your production server.
config :cesium_link, CesiumLinkWeb.Endpoint,
url: [scheme: "https", host: "cesium.link", port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]],
cache_static_manifest: "priv/static/cache_manifest.json"

# Do not print debug messages in production
Expand Down
1 change: 0 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ if config_env() in [:prod, :stg] do
%URI{host: database_host} = URI.parse(database_url)

# Location of root certificates to verify database SSL connections

database_ca_cert_filepath =
System.get_env("DATABASE_CA_CERT_FILEPATH") || "/etc/ssl/certs/ca-certificates.crt"

Expand Down
3 changes: 0 additions & 3 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Config

# Only in tests, remove the complexity from the password hashing algorithm
config :bcrypt_elixir, :log_rounds, 1

# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
db:
image: postgres:14.1
container_name: atomic_db
container_name: cesium_link_db
env_file: .env.dev
environment:
POSTGRES_USER: ${DB_USERNAME:-postgres}
Expand All @@ -12,7 +12,7 @@ services:
volumes:
- /var/lib/postgresql/data
web:
container_name: atomic_web
container_name: cesium_link_web
env_file: .env.dev
environment:
MIX_ENV: ${MIX_ENV:-dev}
Expand Down
29 changes: 29 additions & 0 deletions fly-prod.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
app = "cesium-link-prod"
primary_region = "mad"
kill_signal = "SIGTERM"

[deploy]
release_command = "/app/bin/migrate"

[env]
MIX_ENV = "prod"
PHX_HOST = "cesium.link"
PORT = "8080"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[http_service.concurrency]
type = "connections"
hard_limit = 1000
soft_limit = 1000

[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1
2 changes: 0 additions & 2 deletions fly-stg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ app = "cesium-link-stg"
primary_region = "mad"
kill_signal = "SIGTERM"

[build]

[deploy]
release_command = "/app/bin/migrate"

Expand Down
7 changes: 2 additions & 5 deletions lib/cesium_link/links/link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ defmodule CesiumLink.Links.Link do
@moduledoc """
Link schema.
"""
use Ecto.Schema
import Ecto.Changeset
use CesiumLink.Schema

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

@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "links" do
field :archived, :boolean, default: false
field :attention, :boolean, default: false
Expand All @@ -29,6 +26,6 @@ defmodule CesiumLink.Links.Link do
|> cast(attrs, @required_fields ++ @optional_fields)
|> unique_constraint(:index)
|> validate_required(@required_fields)
|> validate_format(:url, ~r{^https?://}, message: "must start with http:// or https://")
|> validate_url(:url)
end
end
8 changes: 3 additions & 5 deletions lib/cesium_link/redirects/redirect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ defmodule CesiumLink.Redirects.Redirect do
@moduledoc """
Redirect schema.
"""
use Ecto.Schema
import Ecto.Changeset
use CesiumLink.Schema

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

@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "redirects" do
field :name, :string
field :slug, :string
Expand All @@ -26,9 +23,10 @@ defmodule CesiumLink.Redirects.Redirect do
redirect
|> cast(attrs, @required_fields ++ @optional_fields)
|> validate_required(@required_fields)
|> validate_format(:url, ~r{^https?://}, message: "must start with http:// or https://")
|> validate_url(:url)
|> validate_format(:slug, ~r{^[a-z0-9-]+$},
message: "must contain only lowercase letters, numbers, and hyphens"
)
|> unique_constraint([:slug, :type], message: "already in use")
end
end
26 changes: 26 additions & 0 deletions lib/cesium_link/schema.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defmodule CesiumLink.Schema do
@moduledoc """
The application Schema for all the modules, providing Ecto.UUIDs as default
id.
"""
import Ecto.Changeset

defmacro __using__(_) do
quote do
use Ecto.Schema
import Ecto.Changeset

@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id

def validate_url(changeset, field) do
changeset
|> validate_format(
:url,
~r/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/,
message: "must start with http:// or https:// and have a valid domain"
)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/cesium_link_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ defmodule CesiumLinkWeb.CoreComponents do
end

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

0 comments on commit 7927638

Please sign in to comment.