Browse Source

chore(get) it popping

jackyalcine 1 year ago
parent
commit
fa67ff36a0
Signed by: Jacky Alciné <yo@jacky.wtf> GPG Key ID: 537A4F904B15268D

+ 0
- 4
lib/indiemark/scanner/api.ex View File

@@ -3,9 +3,6 @@ defmodule IndieMark.Scanner.Api do
3 3
   alias IndieMark.Scanner.{Level1, Level2}
4 4
 
5 5
   before do
6
-    plug(Plug.Head)
7
-    plug(IndieMark.Scanner.Plug.CORS)
8
-
9 6
     plug(
10 7
       Plug.Parsers,
11 8
       pass: ["*/*"],
@@ -24,7 +21,6 @@ defmodule IndieMark.Scanner.Api do
24 21
     )
25 22
 
26 23
     plug(:fetch_session)
27
-    plug(Plug.CSRFProtection, session_key: :csrf)
28 24
   end
29 25
 
30 26
   get :version do

+ 6
- 0
lib/indiemark/scanner/client.ex View File

@@ -0,0 +1,6 @@
1
+defmodule IndieMark.Scanner.Client do
2
+  use Maru.Router
3
+
4
+  static_path = Path.join(File.cwd!(), "web/dist")
5
+  plug(Plug.Static, at: "/", from: static_path, gzip: true)
6
+end

+ 4
- 27
lib/indiemark/scanner/router.ex View File

@@ -1,6 +1,6 @@
1 1
 defmodule IndieMark.Scanner.Router do
2 2
   use Maru.Router
3
-  alias IndieMark.Scanner.{Level1, Level2}
3
+  alias IndieMark.Scanner.{Api, Client}
4 4
 
5 5
   before do
6 6
     plug(Plug.Logger)
@@ -8,16 +8,6 @@ defmodule IndieMark.Scanner.Router do
8 8
     plug(IndieMark.Scanner.Plug.CORS)
9 9
     plug(Plug.Head)
10 10
 
11
-    plug(
12
-      Plug.Parsers,
13
-      pass: ["*/*"],
14
-      json_decoder: Poison,
15
-      parsers: [:urlencoded, :json, :multipart]
16
-    )
17
-
18
-    static_path = Path.join(File.cwd!(), "web/dist")
19
-    plug(Plug.Static, at: "/", from: static_path, gzip: true)
20
-
21 11
     plug(
22 12
       Plug.Session,
23 13
       encryption_salt: 'a_salt',
@@ -32,24 +22,11 @@ defmodule IndieMark.Scanner.Router do
32 22
     plug(Plug.CSRFProtection, session_key: :csrf)
33 23
   end
34 24
 
35
-  mount Api
36
-  mount Client
37
-
38
-  resource :scans do
39
-    params do
40
-      requires(:domain, type: String)
41
-    end
42
-    put :new do
43
-      conn
44
-      |> json(%{
45
-        level1: Level1.scan(params[:domain]),
46
-        level2: Level2.scan(params[:domain])
47
-      })
48
-    end
49
-  end
50
-
51 25
   get "/" do
52 26
     conn
53 27
     |> redirect("/index.html", permanent: true)
54 28
   end
29
+
30
+  mount Api
31
+  mount Client
55 32
 end

+ 127
- 0
nginx.conf.sigil View File

@@ -0,0 +1,127 @@
1
+# vim: set ft=nginx.sigil :
2
+{{ range $port_map := .PROXY_PORT_MAP | split " " }}
3
+{{ $port_map_list := $port_map | split ":" }}
4
+{{ $scheme := index $port_map_list 0 }}
5
+{{ $listen_port := index $port_map_list 1 }}
6
+{{ $upstream_port := index $port_map_list 2 }}
7
+
8
+{{ if eq $scheme "http" }}
9
+server {
10
+  listen      [::]:{{ $listen_port }};
11
+  listen      {{ $listen_port }};
12
+  {{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
13
+  access_log  /var/log/nginx/{{ $.APP }}-access.log;
14
+  error_log   /var/log/nginx/{{ $.APP }}-error.log;
15
+{{ if (and (eq $listen_port "80") ($.SSL_INUSE)) }}
16
+  return 301 https://$host:{{ $.PROXY_SSL_PORT }}$request_uri;
17
+{{ else }}
18
+  location    / {
19
+
20
+    gzip on;
21
+    gzip_min_length  1100;
22
+    gzip_buffers  4 32k;
23
+    gzip_types    text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml  application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
24
+    gzip_vary on;
25
+    gzip_comp_level  6;
26
+
27
+    proxy_pass  http://{{ $.APP }}-{{ $upstream_port }};
28
+    proxy_http_version 1.1;
29
+    proxy_set_header Upgrade $http_upgrade;
30
+    proxy_set_header Connection "upgrade";
31
+    proxy_set_header Host $http_host;
32
+    proxy_set_header X-Forwarded-Proto $scheme;
33
+    proxy_set_header X-Forwarded-For $remote_addr;
34
+    proxy_set_header X-Forwarded-Port $server_port;
35
+    proxy_set_header X-Request-Start $msec;
36
+    try_files $uri $uri/ /index.html =404;
37
+  }
38
+  include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
39
+
40
+  error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
41
+  location /400-error.html {
42
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
43
+    internal;
44
+  }
45
+
46
+  error_page 404 /404-error.html;
47
+  location /404-error.html {
48
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
49
+    internal;
50
+  }
51
+
52
+  error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
53
+  location /500-error.html {
54
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
55
+    internal;
56
+  }
57
+{{ end }}
58
+}
59
+{{ else if eq $scheme "https"}}
60
+server {
61
+  listen      [::]:{{ $listen_port }} ssl {{ if eq $.HTTP2_SUPPORTED "true" }}http2{{ else if eq $.SPDY_SUPPORTED "true" }}spdy{{ end }};
62
+  listen      {{ $listen_port }} ssl {{ if eq $.HTTP2_SUPPORTED "true" }}http2{{ else if eq $.SPDY_SUPPORTED "true" }}spdy{{ end }};
63
+  {{ if $.SSL_SERVER_NAME }}server_name {{ $.SSL_SERVER_NAME }}; {{ end }}
64
+  {{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }}
65
+  access_log  /var/log/nginx/{{ $.APP }}-access.log;
66
+  error_log   /var/log/nginx/{{ $.APP }}-error.log;
67
+
68
+  ssl_certificate     {{ $.APP_SSL_PATH }}/server.crt;
69
+  ssl_certificate_key {{ $.APP_SSL_PATH }}/server.key;
70
+  ssl_protocols       TLSv1.2;
71
+  ssl_prefer_server_ciphers on;
72
+
73
+  keepalive_timeout   70;
74
+  {{ if and (eq $.SPDY_SUPPORTED "true") (ne $.HTTP2_SUPPORTED "true") }}add_header          Alternate-Protocol  {{ $.PROXY_SSL_PORT }}:npn-spdy/2;{{ end }}
75
+
76
+  location    / {
77
+
78
+    gzip on;
79
+    gzip_min_length  1100;
80
+    gzip_buffers  4 32k;
81
+    gzip_types    text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml  application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
82
+    gzip_vary on;
83
+    gzip_comp_level  6;
84
+
85
+    proxy_pass  http://{{ $.APP }}-{{ $upstream_port }};
86
+    {{ if eq $.HTTP2_PUSH_SUPPORTED "true" }}http2_push_preload on; {{ end }}
87
+    proxy_http_version 1.1;
88
+    proxy_set_header Upgrade $http_upgrade;
89
+    proxy_set_header Connection "upgrade";
90
+    proxy_set_header Host $http_host;
91
+    proxy_set_header X-Forwarded-Proto $scheme;
92
+    proxy_set_header X-Forwarded-For $remote_addr;
93
+    proxy_set_header X-Forwarded-Port $server_port;
94
+    proxy_set_header X-Request-Start $msec;
95
+    try_files $uri $uri/ /index.html =404;
96
+  }
97
+  include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
98
+
99
+  error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
100
+  location /400-error.html {
101
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
102
+    internal;
103
+  }
104
+
105
+  error_page 404 /404-error.html;
106
+  location /404-error.html {
107
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
108
+    internal;
109
+  }
110
+
111
+  error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
112
+  location /500-error.html {
113
+    root {{ $.DOKKU_LIB_ROOT }}/data/nginx-vhosts/dokku-errors;
114
+    internal;
115
+  }
116
+}
117
+{{ end }}{{ end }}
118
+
119
+{{ if $.DOKKU_APP_LISTENERS }}
120
+{{ range $upstream_port := $.PROXY_UPSTREAM_PORTS | split " " }}
121
+upstream {{ $.APP }}-{{ $upstream_port }} {
122
+{{ range $listeners := $.DOKKU_APP_LISTENERS | split " " }}
123
+{{ $listener_list := $listeners | split ":" }}
124
+{{ $listener_ip := index $listener_list 0 }}
125
+  server {{ $listener_ip }}:{{ $upstream_port }};{{ end }}
126
+}
127
+{{ end }}{{ end }}

+ 15
- 3
test/indiemark/scanner/level2_test.exs View File

@@ -5,8 +5,20 @@ defmodule IndieMark.Scanner.Level2Test do
5 5
 
6 6
   @uri "https://jacky.wtf"
7 7
 
8
-  test "page contains a valid h-card" do
9
-    subject = Level.resolve_hcard(@uri)
10
-    assert {:ok, _hcard} = subject
8
+  describe "h-card" do
9
+    test "page contains a valid card with icon"
10
+    test "page contains a valid card with no icon"
11
+  end
12
+
13
+  describe "post listing" do
14
+    test "page has a feed for posts"
15
+    test "page has more than two posts"
16
+    test "page has UI for searching posts"
17
+  end
18
+
19
+  describe "post UI" do
20
+    test "page provides navigation between posts"
21
+    test "post has link to share on other platforms"
22
+    test "post has syndication links"
11 23
   end
12 24
 end

+ 1
- 2
test/indiemark/scanner/router_test.exs View File

@@ -4,7 +4,6 @@ defmodule IndieMark.Scanner.ApiTest do
4 4
   alias IndieMark.Scanner.Api
5 5
 
6 6
   describe "GET /api/version" do
7
-    test "reports version of API" do
8
-    end
7
+    test "reports version of API"
9 8
   end
10 9
 end

Loading…
Cancel
Save