mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-21 23:44:30 +00:00
add make test and Remove vue-cli serve
This commit is contained in:
parent
e1e410d595
commit
ff7fd460f0
14 changed files with 47 additions and 79 deletions
3
Makefile
3
Makefile
|
@ -11,9 +11,6 @@ stop:
|
||||||
docker-compose down
|
docker-compose down
|
||||||
@bash docker/message.sh "stopped"
|
@bash docker/message.sh "stopped"
|
||||||
test: stop
|
test: stop
|
||||||
@bash docker/message.sh "Building front"
|
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.test.yml run front yarn run build
|
|
||||||
@bash docker/message.sh "Front built"
|
|
||||||
@bash docker/message.sh "Running tests"
|
@bash docker/message.sh "Running tests"
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.test.yml run api mix test
|
docker-compose -f docker-compose.yml -f docker-compose.test.yml run api mix test
|
||||||
@bash docker/message.sh "Tests runned"
|
@bash docker/message.sh "Tests runned"
|
||||||
|
|
|
@ -17,7 +17,9 @@ config :mobilizon, MobilizonWeb.Endpoint,
|
||||||
debug_errors: true,
|
debug_errors: true,
|
||||||
code_reloader: true,
|
code_reloader: true,
|
||||||
check_origin: false,
|
check_origin: false,
|
||||||
watchers: []
|
watchers: [
|
||||||
|
yarn: ["run", "dev", cd: Path.expand("../js", __DIR__)]
|
||||||
|
]
|
||||||
|
|
||||||
# ## SSL Support
|
# ## SSL Support
|
||||||
#
|
#
|
||||||
|
|
|
@ -5,13 +5,12 @@ services:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: mobilizon_test
|
POSTGRES_DB: mobilizon_test
|
||||||
front:
|
|
||||||
restart: "no"
|
|
||||||
api:
|
api:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
environment:
|
environment:
|
||||||
MIX_ENV: "test"
|
MIX_ENV: "test"
|
||||||
MOBILIZON_DATABASE_DBNAME: mobilizon_test
|
MOBILIZON_DATABASE_DBNAME: mobilizon_test
|
||||||
|
MOBILIZON_INSTANCE_HOST: mobilizon.test
|
||||||
command: "mix test"
|
command: "mix test"
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
|
|
|
@ -10,18 +10,6 @@ services:
|
||||||
POSTGRES_DB: mobilizon_dev
|
POSTGRES_DB: mobilizon_dev
|
||||||
volumes:
|
volumes:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
|
||||||
front:
|
|
||||||
container_name: mobilizon_front
|
|
||||||
restart: unless-stopped
|
|
||||||
build: ./js
|
|
||||||
volumes:
|
|
||||||
- '.:/app'
|
|
||||||
ports:
|
|
||||||
- "8888:8080"
|
|
||||||
command: yarn run dev
|
|
||||||
|
|
||||||
api:
|
api:
|
||||||
container_name: mobilizon_api
|
container_name: mobilizon_api
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -32,13 +20,12 @@ services:
|
||||||
- "4000:4001"
|
- "4000:4001"
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- front
|
|
||||||
environment:
|
environment:
|
||||||
MIX_ENV: "dev"
|
MIX_ENV: "dev"
|
||||||
MOBILIZON_INSTANCE_NAME: My Mobilizon Instance
|
MOBILIZON_INSTANCE_NAME: My Mobilizon Instance
|
||||||
MOBILIZON_INSTANCE_HOST: mobilizon.me
|
MOBILIZON_INSTANCE_HOST: mobilizon.me
|
||||||
MOBILIZON_INSTANCE_EMAIL: noreply@mobilizon.me
|
MOBILIZON_INSTANCE_EMAIL: noreply@mobilizon.me
|
||||||
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "false"
|
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
|
||||||
MOBILIZON_DATABASE_PASSWORD: postgres
|
MOBILIZON_DATABASE_PASSWORD: postgres
|
||||||
MOBILIZON_DATABASE_USERNAME: postgres
|
MOBILIZON_DATABASE_USERNAME: postgres
|
||||||
MOBILIZON_DATABASE_DBNAME: mobilizon_dev
|
MOBILIZON_DATABASE_DBNAME: mobilizon_dev
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
FROM node:10
|
|
||||||
|
|
||||||
LABEL maintainer="tcit"
|
|
||||||
|
|
||||||
RUN yarn install
|
|
||||||
RUN yarn upgrade node-sass
|
|
||||||
|
|
||||||
WORKDIR /app/js
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
|
@ -6,7 +6,7 @@
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
"lint": "vue-cli-service lint",
|
"lint": "vue-cli-service lint",
|
||||||
"analyze-bundle": "yarn run build -- --report-json && webpack-bundle-analyzer ../priv/static/report.json",
|
"analyze-bundle": "yarn run build -- --report-json && webpack-bundle-analyzer ../priv/static/report.json",
|
||||||
"dev": "vue-cli-service serve",
|
"dev": "vue-cli-service build --watch",
|
||||||
"test:e2e": "vue-cli-service test:e2e",
|
"test:e2e": "vue-cli-service test:e2e",
|
||||||
"test:unit": "vue-cli-service test:unit",
|
"test:unit": "vue-cli-service test:unit",
|
||||||
"prepare": "patch-package"
|
"prepare": "patch-package"
|
||||||
|
|
|
@ -4,7 +4,7 @@ const path = require('path');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
lintOnSave: false,
|
lintOnSave: false,
|
||||||
runtimeCompiler: true,
|
runtimeCompiler: true,
|
||||||
outputDir: '../priv/static',
|
outputDir: '../priv/static/js',
|
||||||
configureWebpack: {
|
configureWebpack: {
|
||||||
plugins: [
|
plugins: [
|
||||||
new Dotenv({ path: path.resolve(process.cwd(), '../.env') }),
|
new Dotenv({ path: path.resolve(process.cwd(), '../.env') }),
|
||||||
|
@ -18,6 +18,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
output: {
|
||||||
|
filename: 'app.js'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
chainWebpack: config => {
|
chainWebpack: config => {
|
||||||
config
|
config
|
||||||
|
|
|
@ -3,19 +3,15 @@ defmodule MobilizonWeb.PageController do
|
||||||
Controller to load our webapp
|
Controller to load our webapp
|
||||||
"""
|
"""
|
||||||
use MobilizonWeb, :controller
|
use MobilizonWeb, :controller
|
||||||
alias Mobilizon.Service.Metadata
|
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.Actors
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.{Event, Comment}
|
alias Mobilizon.Events.{Event, Comment}
|
||||||
|
|
||||||
plug(:put_layout, false)
|
|
||||||
action_fallback(MobilizonWeb.FallbackController)
|
action_fallback(MobilizonWeb.FallbackController)
|
||||||
|
|
||||||
def index(conn, _params) do
|
def index(conn, _params) do
|
||||||
conn
|
render conn, "app.html"
|
||||||
|> put_resp_content_type("text/html")
|
|
||||||
|> send_file(200, "priv/static/index.html")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def actor(conn, %{"name" => name}) do
|
def actor(conn, %{"name" => name}) do
|
||||||
|
@ -77,16 +73,6 @@ defmodule MobilizonWeb.PageController do
|
||||||
|
|
||||||
# Inject OpenGraph information
|
# Inject OpenGraph information
|
||||||
defp render_with_meta(conn, object) do
|
defp render_with_meta(conn, object) do
|
||||||
{:ok, index_content} = File.read(index_file_path())
|
render conn, "app.html", object: object
|
||||||
tags = Metadata.build_tags(object)
|
|
||||||
response = String.replace(index_content, "<!--server-generated-meta-->", tags)
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_resp_content_type("text/html")
|
|
||||||
|> send_resp(200, response)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp index_file_path() do
|
|
||||||
Path.join(Application.app_dir(:mobilizon, "priv/static/"), "index.html")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ defmodule MobilizonWeb.Endpoint do
|
||||||
at: "/",
|
at: "/",
|
||||||
from: :mobilizon,
|
from: :mobilizon,
|
||||||
gzip: false,
|
gzip: false,
|
||||||
only: ~w(css fonts images js favicon.ico robots.txt index.html)
|
only: ~w(css fonts images js favicon.ico robots.txt)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Code reloading can be explicitly enabled under the
|
# Code reloading can be explicitly enabled under the
|
||||||
|
|
23
lib/mobilizon_web/templates/layout/app.html.eex
Normal file
23
lib/mobilizon_web/templates/layout/app.html.eex
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="has-navbar-fixed-top">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<link rel="icon" href="<%= static_path(@conn, "/js/favicon.ico") %>">
|
||||||
|
<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">
|
||||||
|
<title>mobilizon</title>
|
||||||
|
<%= if assigns[:object], do: Metadata.build_tags(@object) %>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<strong>We're sorry but mobilizon doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
|
</noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
5
lib/mobilizon_web/views/layout_view.ex
Normal file
5
lib/mobilizon_web/views/layout_view.ex
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
defmodule MobilizonWeb.LayoutView do
|
||||||
|
use MobilizonWeb, :view
|
||||||
|
alias Mobilizon.Service.Metadata
|
||||||
|
|
||||||
|
end
|
|
@ -1,17 +1,8 @@
|
||||||
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
||||||
alias Phoenix.HTML
|
|
||||||
alias Phoenix.HTML.Tag
|
alias Phoenix.HTML.Tag
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
require Logger
|
|
||||||
|
|
||||||
def build_tags(%Actor{} = actor) do
|
def build_tags(%Actor{} = actor) do
|
||||||
actor
|
|
||||||
|> do_build_tags()
|
|
||||||
|> Enum.map(&HTML.safe_to_string/1)
|
|
||||||
|> Enum.reduce("", fn tag, acc -> acc <> tag end)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp do_build_tags(%Actor{} = actor) do
|
|
||||||
[
|
[
|
||||||
Tag.tag(:meta, property: "og:title", content: Actor.display_name_and_username(actor)),
|
Tag.tag(:meta, property: "og:title", content: Actor.display_name_and_username(actor)),
|
||||||
Tag.tag(:meta, property: "og:url", content: actor.url),
|
Tag.tag(:meta, property: "og:url", content: actor.url),
|
||||||
|
|
|
@ -4,13 +4,6 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Comment do
|
||||||
alias Mobilizon.Events.Comment
|
alias Mobilizon.Events.Comment
|
||||||
|
|
||||||
def build_tags(%Comment{} = comment) do
|
def build_tags(%Comment{} = comment) do
|
||||||
comment
|
|
||||||
|> do_build_tags()
|
|
||||||
|> Enum.map(&HTML.safe_to_string/1)
|
|
||||||
|> Enum.reduce("", fn tag, acc -> acc <> tag end)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp do_build_tags(%Comment{} = comment) do
|
|
||||||
[
|
[
|
||||||
Tag.tag(:meta, property: "og:title", content: comment.actor.preferred_username),
|
Tag.tag(:meta, property: "og:title", content: comment.actor.preferred_username),
|
||||||
Tag.tag(:meta, property: "og:url", content: comment.url),
|
Tag.tag(:meta, property: "og:url", content: comment.url),
|
||||||
|
|
|
@ -5,15 +5,6 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
|
||||||
alias MobilizonWeb.JsonLD.ObjectView
|
alias MobilizonWeb.JsonLD.ObjectView
|
||||||
|
|
||||||
def build_tags(%Event{} = event) do
|
def build_tags(%Event{} = event) do
|
||||||
event
|
|
||||||
|> do_build_tags()
|
|
||||||
|> Enum.map(&HTML.safe_to_string/1)
|
|
||||||
|> Enum.reduce("", fn tag, acc -> acc <> tag end)
|
|
||||||
|> Kernel.<>(build_json_ld_schema(event))
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build OpenGraph & Twitter Tags
|
|
||||||
defp do_build_tags(%Event{} = event) do
|
|
||||||
[
|
[
|
||||||
Tag.tag(:meta, property: "og:title", content: event.title),
|
Tag.tag(:meta, property: "og:title", content: event.title),
|
||||||
Tag.tag(:meta, property: "og:url", content: event.url),
|
Tag.tag(:meta, property: "og:url", content: event.url),
|
||||||
|
@ -21,14 +12,15 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
|
||||||
Tag.tag(:meta, property: "og:type", content: "website"),
|
Tag.tag(:meta, property: "og:type", content: "website"),
|
||||||
Tag.tag(:meta, property: "og:image", content: event.thumbnail),
|
Tag.tag(:meta, property: "og:image", content: event.thumbnail),
|
||||||
Tag.tag(:meta, property: "og:image", content: event.large_image),
|
Tag.tag(:meta, property: "og:image", content: event.large_image),
|
||||||
Tag.tag(:meta, property: "twitter:card", content: "summary_large_image")
|
Tag.tag(:meta, property: "twitter:card", content: "summary_large_image"),
|
||||||
|
~s{<script type="application/ld+json">#{json(event)}</script>} |> HTML.raw()
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Insert JSON-LD schema by hand because Tag.content_tag wants to escape it
|
# Insert JSON-LD schema by hand because Tag.content_tag wants to escape it
|
||||||
defp build_json_ld_schema(%Event{} = event) do
|
defp json(%Event{} = event) do
|
||||||
"<script type=\"application\/ld+json\">" <>
|
"event.json"
|
||||||
(ObjectView.render("event.json", %{event: event})
|
|> ObjectView.render(%{event: event})
|
||||||
|> Jason.encode!()) <> "</script>"
|
|> Jason.encode!()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue