Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PZ
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
PZ
Commits
0304149c
Verified
Commit
0304149c
authored
2 years ago
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Podpora title
parent
41e533f7
No related branches found
No related tags found
No related merge requests found
Pipeline
#11091
passed
2 years ago
Stage: build
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
VERSION
+1
-1
1 addition, 1 deletion
VERSION
lib/PZ/Controller/Shortcut.pm
+14
-4
14 additions, 4 deletions
lib/PZ/Controller/Shortcut.pm
openapi.yaml
+4
-0
4 additions, 0 deletions
openapi.yaml
templates/shortcuts.html.ep
+15
-9
15 additions, 9 deletions
templates/shortcuts.html.ep
with
34 additions
and
14 deletions
VERSION
+
1
−
1
View file @
0304149c
2.
3
.0
2.
4
.0
This diff is collapsed.
Click to expand it.
lib/PZ/Controller/Shortcut.pm
+
14
−
4
View file @
0304149c
...
...
@@ -3,6 +3,7 @@ use Mojo::Base 'Mojolicious::Controller', -signatures;
use
Data::Validate::
URI
qw(is_uri)
;
use
Image::PNG::
QRCode
'
qrpng
';
use
Mojo::
UserAgent
;
use
constant
SHORTCUT
=>
qr/^[a-z\d\-]{1,8}$/
;
...
...
@@ -49,7 +50,7 @@ sub create ($c) {
$c
->
openapi
->
valid_input
or
return
;
my
$args
=
$c
->
req
->
json
;
my
$url
=
$args
->
{
url
};
my
$url
=
$c
->
sanitize_url
(
$args
->
{
url
}
)
;
return
$c
->
error
(
400
,
'
Chybná URL adresa!
')
if
!
is_uri
(
$url
);
my
$custom
=
lc
(
$args
->
{
shortcut
});
...
...
@@ -65,8 +66,16 @@ sub create ($c) {
return
$c
->
error
(
400
,
"
Zkratka
$custom
už je použitá
")
if
$exists
;
}
my
$title
=
'';
my
$ua
=
Mojo::
UserAgent
->
new
;
eval
{
$title
=
$ua
->
get
(
$url
)
->
result
->
dom
->
at
('
title
')
->
text
;
};
my
$shortcut
=
$c
->
user
->
add_to_shortcuts
({
url
=>
$c
->
sanitize_url
(
$url
),
url
=>
$url
,
title
=>
$title
,
shortcut
=>
(
$custom
||
$c
->
schema
->
resultset
('
Shortcut
')
->
generate
())
});
...
...
@@ -85,8 +94,9 @@ sub update ($c) {
my
$shortcut
=
$c
->
shortcut
()
||
return
;
return
$c
->
error
(
400
,
'
Chybná URL adresa!
')
if
!
is_uri
(
$c
->
req
->
json
->
{
url
});
$shortcut
->
update
({
code
=>
$c
->
req
->
json
->
{
code
},
url
=>
$c
->
req
->
json
->
{
url
},
code
=>
$c
->
req
->
json
->
{
code
},
url
=>
$c
->
req
->
json
->
{
url
},
title
=>
$c
->
req
->
json
->
{
title
},
});
$c
->
render
(
status
=>
204
,
text
=>
''
);
}
...
...
This diff is collapsed.
Click to expand it.
openapi.yaml
+
4
−
0
View file @
0304149c
...
...
@@ -37,6 +37,10 @@ components:
type
:
string
description
:
URL pro přesměrování
maxLength
:
1024
title
:
type
:
string
description
:
Titulek stránky
maxLength
:
4096
code
:
type
:
integer
description
:
Kód přesměrování
...
...
This diff is collapsed.
Click to expand it.
templates/shortcuts.html.ep
+
15
−
9
View file @
0304149c
...
...
@@ -41,11 +41,11 @@
</thead>
<tbody>
<tr v-for="shortcut in shortcuts" >
<td class="text-bold w-32" @click="show
Edit
(shortcut)" >{{shortcut.shortcut}}</td>
<td class="text-bold w-32" @click="show
Edit
(shortcut)" >{{ formatTimestamp(shortcut.created) }}</td>
<td v-bind:title="shortcut.url" @click="show
Edit
(shortcut)" >{{ stripURL(shortcut.url) }}</td>
<td class="w-24" @click="show
Edit
(shortcut)">{{ shortcut.code == 301 ? '301 trvalé' : '302 dočasné'}}</td>
<td class="w-16 text-right" @click="show
Edit
(shortcut)">{{shortcut.counter}}</td>
<td
v-bind:title="shortcut.title"
class="text-bold w-32" @click="show
Info
(shortcut)" >{{shortcut.shortcut}}</td>
<td class="text-bold w-32" @click="show
Info
(shortcut)" >{{ formatTimestamp(shortcut.created) }}</td>
<td v-bind:title="shortcut.url" @click="show
Info
(shortcut)" >{{ stripURL(shortcut.url) }}</td>
<td class="w-24" @click="show
Info
(shortcut)">{{ shortcut.code == 301 ? '301 trvalé' : '302 dočasné'}}</td>
<td class="w-16 text-right" @click="show
Info
(shortcut)">{{shortcut.counter}}</td>
<td class="w-40">
<i class="ico--link cursor-pointer mx-1" @click="showInfo(shortcut)" title="Zkopirovat odkaz"></i>
<i class="ico--calendar cursor-pointer mx-1" @click="window.location.href ='/shortcut/' + shortcut.id" title="Statistika"></i>
...
...
@@ -65,7 +65,7 @@
<div class="card__body w-80 text-center">
<p class="card-body-text">Zkratka byla zkopírovana do schránky. Pro její sdílení můžete používat i QR kód</p>
<img v-bind:src="'/' + selectedShortcut.shortcut + '/qr.png'" class="mx-auto my-8">
<b>{{ selectedShortcut.full_url }}</b>
<b>
<a v-bind:href="selectedShortcut.full_url">
{{ selectedShortcut.full_url }}</
a></
b>
</div>
</div>
</div>
...
...
@@ -111,7 +111,7 @@
<form class="my-4">
<div class="form-field
form-field--error
form-field--required mb-4">
<div class="form-field form-field--required mb-4">
<label class="form-field__label" for="url">URL</label>
<div class="form-field__wrapper form-field__wrapper--shadowed">
<input type="text" class="text-input form-field__control form-field--required" value="" v-model="selectedShortcut.url" id="url" />
...
...
@@ -119,7 +119,7 @@
<div class="form-field__error" v-if="selectedShortcut.url === ''"></div>
</div>
<div class="form-field
form-field--error
form-field--required mb-4">
<div class="form-field form-field--required mb-4">
<label class="form-field__label" for="code">Typ přesměrování</label>
<div class="form-field__wrapper form-field__wrapper--shadowed select">
<select v-model="selectedShortcut.code" class="select__control form-field__control ">
...
...
@@ -127,7 +127,13 @@
<option value="302">302 dočasné</option>
</select>
</div>
<div class="form-field__error" v-if="shortcut.url === ''"></div>
</div>
<div class="form-field mb-4">
<label class="form-field__label" for="code">Titulek</label>
<div class="form-field__wrapper form-field__wrapper--shadowed">
<textarea class="text-input form-field__control" v-model="selectedShortcut.title" rows="5" cols="40" placeholder="Titulek stránky"></textarea>
</div>
</div>
<button class="btn btn--grey-500 btn--hoveractive" @click.prevent="updateShortcut">
...
...
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