Skip to content

Commit 863859d

Browse files
authored
feature: web: support github login and deferred deletion. (#88)
1 parent 2891c6a commit 863859d

29 files changed

+1977
-47
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ install:
9494
$(CP) -r bin $(DESTDIR)bin
9595
$(CP) -r util $(DESTDIR)util
9696
$(CP) -r web/conf $(DESTDIR)web/conf
97+
rm -f $(DESTDIR)web/conf/config.ini
9798
$(CP) -r web/css $(DESTDIR)web/css
99+
$(CP) -r web/js $(DESTDIR)web/js
98100
$(CP) -r web/images $(DESTDIR)web/images
99101
$(CP) -r web/docs/ $(DESTDIR)web/docs/
100102
$(CP) -r web/lua $(DESTDIR)web/lua

init.sql

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ create table users (
3232
updated_at timestamp with time zone not null default now()
3333
);
3434

35+
drop table if exists users_sessions cascade;
36+
37+
create table users_sessions (
38+
id serial primary key,
39+
user_id integer not null,
40+
token text not null unique,
41+
ip text not null,
42+
user_agent text,
43+
last_active_at timestamp with time zone default now(),
44+
created_at timestamp with time zone not null default now(),
45+
updated_at timestamp with time zone not null default now()
46+
);
47+
3548
drop table if exists orgs cascade;
3649

3750
-- for github organizations
@@ -107,11 +120,12 @@ create table uploads (
107120
client_addr inet not null,
108121
failed boolean not null default FALSE,
109122
indexed boolean not null default FALSE,
110-
123+
is_deleted boolean,
111124
ts_idx tsvector,
112125

113126
created_at timestamp with time zone not null default now(),
114-
updated_at timestamp with time zone not null default now()
127+
updated_at timestamp with time zone not null default now(),
128+
deleted_at_time integer
115129
);
116130

117131
drop function if exists uploads_trigger() cascade;

web/conf/config.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[common]
2+
env = "dev"
3+
deferred_deletion_days=3
4+
5+
[db]
6+
host = 127.0.0.1
7+
port = 5432
8+
max_idle_timeout = 60
9+
pool_size = 5
10+
database = "opm"
11+
user = "opm"
12+
password = "buildecosystem"
13+
14+
[github_oauth]
15+
client_id=abc123
16+
client_secret=abc123
17+
host=https://github.com

web/conf/nginx.conf

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ http {
2727
lua_shared_dict global_github_limit 100k;
2828
lua_shared_dict bad_users 50m;
2929

30+
server_tokens off;
31+
3032
init_by_lua_block {
31-
-- preload Lua modules
32-
require "opmserver"
33+
require "resty.core"
34+
require("opmserver")
35+
require("opmserver.init").init()
3336
}
3437

35-
server_tokens off;
38+
init_worker_by_lua_block {
39+
require("opmserver.init").init_worker()
40+
}
3641

3742
server {
3843
server_name opm.openresty.org;
@@ -155,11 +160,25 @@ http {
155160
alias css;
156161
}
157162

163+
164+
location /js {
165+
expires 1d;
166+
alias js;
167+
}
168+
158169
location /images {
159170
expires 1d;
160171
alias images;
161172
}
162173

174+
location /api/ {
175+
default_type application/json;
176+
177+
content_by_lua_block {
178+
require("opmserver").do_web()
179+
}
180+
}
181+
163182
location / {
164183
default_type text/html;
165184
expires 10s;

web/css/main.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,42 @@ pre {
309309
color: red;
310310
margin-left: 2px;
311311
font-size: 18px; }
312+
313+
.sign-in {
314+
margin: 0 auto;
315+
text-align: center; }
316+
317+
.button {
318+
display: inline-block;
319+
text-decoration: none;
320+
background: #4d8d89;
321+
line-height: 35px;
322+
height: 35px;
323+
padding: 0 30px;
324+
font-size: 16px;
325+
font-family: 'Open Sans', sans-serif;
326+
border: 0;
327+
border-radius: 5px;
328+
color: #FFF;
329+
cursor: pointer;
330+
}
331+
332+
.delete-btn, .cancel-deleting-btn{
333+
width: 1rem !important;
334+
height: 1rem !important;
335+
background-position: 0 15px;
336+
}
337+
338+
.delete-pkg, .cancel-deleting-pkg{
339+
overflow: hidden;
340+
}
341+
342+
.delete-pkg:hover img{
343+
transform: translateY(-50px);
344+
filter: drop-shadow(#AF0C0C 0 50px);
345+
}
346+
347+
.cancel-deleting-pkg:hover img{
348+
transform: translateY(-50px);
349+
filter: drop-shadow(#AF0C0C 0 50px);
350+
}

web/images/cancel.png

799 Bytes
Loading

web/images/delete.png

1.52 KB
Loading

web/js/jquery.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)