Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
piratar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
piratar
Commits
1efa8685
Verified
Commit
1efa8685
authored
Jan 28, 2023
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Verze 2.0. Simplifikace, jen chobotnice
parent
cc6b66a8
No related branches found
No related tags found
No related merge requests found
Pipeline
#11255
passed
Jan 28, 2023
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
Dockerfile
+3
-2
3 additions, 2 deletions
Dockerfile
piratar
+16
-56
16 additions, 56 deletions
piratar
piratar.conf
+0
-12
0 additions, 12 deletions
piratar.conf
with
20 additions
and
71 deletions
.gitlab-ci.yml
+
1
−
1
View file @
1efa8685
...
...
@@ -2,7 +2,7 @@ image: docker:20.10.9
variables
:
DOCKER_TLS_CERTDIR
:
"
/certs"
IMAGE_VER
:
1.1
.0
IMAGE_VER
:
2.0
.0
services
:
-
docker:20.10.9-dind
...
...
This diff is collapsed.
Click to expand it.
Dockerfile
+
3
−
2
View file @
1efa8685
FROM
alpine:latest
RUN
apk update
&&
apk add perl-mojolicious perl-io-socket-ssl
RUN
apk update
&&
apk add perl-mojolicious perl-io-socket-ssl perl-app-cpanminus make
RUN
cpanm GraphQL::Client
ADD
. /opt/piratar
WORKDIR
/opt/piratar
USER
nobody
EXPOSE
3000
CMD
hypnotoad -f
/opt/piratar/piratar
CMD
/opt/piratar/piratar
daemon -c 3000
This diff is collapsed.
Click to expand it.
piratar
+
16
−
56
View file @
1efa8685
...
...
@@ -2,12 +2,7 @@
use
Mojolicious::
Lite
-
signatures
;
use
Mojo::
UserAgent
;
use
Mojolicious::
Static
;
my
$config
=
plugin
'
Config
';
my
$ua
=
Mojo::
UserAgent
->
new
;
my
$cache
=
$config
->
{
cache
};
mkdir
$cache
if
!
-
d
$cache
;
use
GraphQL::
Client
;
get
'
/*url
'
=>
sub
($c) {
...
...
@@ -15,57 +10,22 @@ get '/*url' => sub ($c) {
$username
=~
s/^.*\///
;
$username
=~
s/\.(png|jpg|gif)$//
;
if
(
my
$url
=
check
(
$c
,
$username
))
{
$c
->
redirect_to
(
$url
);
}
else
{
$c
->
reply
->
file
('
default.jpg
');
}
};
app
->
start
;
sub
urls
( $c, $photos, $order ) {
my
@default
=
split
/\W+/
,
$c
->
config
->
{
sources
};
my
@custom
=
();
foreach
my
$p
(
split
'',
$order
//
''
)
{
push
@custom
,
$default
[
$p
]
if
$p
<
scalar
@default
;
}
my
%photos
=
map
{
$_
->
{
source
}
=>
$_
->
{
url
}
}
@
{
$photos
};
return
grep
{
defined
}
map
{
$photos
{
$_
}
}
(
@custom
,
@default
);
}
sub
check
($c, $username ) {
my
(
$order
,
$photos
,
$photo
);
$order
=
$
1
if
$username
=~
s/~(\d+)$//
;
eval
{
$photos
=
$ua
->
get
(
sprintf
(
$config
->
{
iapi_get_photos
},
$username
)
)
->
result
->
json
;
};
if
(
!
$photos
||
ref
$photos
ne
'
ARRAY
'
)
{
$c
->
render
(
status
=>
404
,
text
=>
'
not found
'
);
my
$gq
=
GraphQL::
Client
->
new
(
url
=>
$ENV
{
OCTOPUS
});
my
$rc
=
$gq
->
execute
(
qq[ query MyQuery {
allPeople(filters: {username: {iExact: "$username"}}) {
edges { node { profilePhoto } }
}}]
,
);
if
(
!
$rc
->
{
errors
}
&&
$rc
->
{
data
}
)
{
my
$user
=
$rc
->
{
data
}{
allPeople
}{
edges
}[
0
]{
node
};
if
(
my
$photo
=
$user
->
{
profilePhoto
})
{
$c
->
redirect_to
(
$photo
);
return
;
}
foreach
my
$url
(
urls
(
$c
,
$photos
,
$order
)
)
{
my
$res
;
eval
{
$res
=
$ua
->
head
(
$url
)
->
result
;
};
$c
->
app
->
log
->
info
("
CHECK
$url
");
$c
->
app
->
log
->
error
(
$@
),
next
if
$@
;
$c
->
app
->
log
->
error
(
$res
->
message
),
next
if
!
$res
->
is_success
;
$photo
=
$url
;
last
;
}
return
$photo
;
$c
->
reply
->
file
('
default.jpg
');
};
}
app
->
start
;
This diff is collapsed.
Click to expand it.
piratar.conf
deleted
100644 → 0
+
0
−
12
View file @
cc6b66a8
{
iapi_get_photos
=>
'https://iapi.pirati.cz/v1/user/photos?username=%s'
,
sources
=>
'lide_0 lide_1 lide_2 web_main web_local gravatar_0 gravatar_1 gravatar_2'
,
cache
=>
'/tmp/cache'
,
hypnotoad
=> {
listen
=> [
'http://0.0.0.0:3000'
],
workers
=>
10
,
proxy
=>
1
,
pid_file
=>
'/tmp/piratar.pid'
,
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment