Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Portal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fachschaft
Portal
Commits
5ab9f823
Verified
Commit
5ab9f823
authored
8 months ago
by
Jakob Moser
Browse files
Options
Downloads
Patches
Plain Diff
Implement using exfiltrated metadata
parent
5e778b5d
No related branches found
No related tags found
No related merge requests found
Pipeline
#6533
passed
8 months ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
portal/static/js/components/pages/Fachschaftssitzung.mjs
+20
-19
20 additions, 19 deletions
portal/static/js/components/pages/Fachschaftssitzung.mjs
portal/static/js/gitlab.mjs
+51
-18
51 additions, 18 deletions
portal/static/js/gitlab.mjs
with
71 additions
and
37 deletions
portal/static/js/components/pages/Fachschaftssitzung.mjs
+
20
−
19
View file @
5ab9f823
...
...
@@ -2,7 +2,7 @@ import { Base } from "./Base.mjs"
import
{
Agenda
}
from
"
../pieces/Agenda.mjs
"
import
{
getKey
}
from
"
../../account.mjs
"
import
{
ButtonAndTextLink
}
from
"
../pieces/ButtonAndTextLink.mjs
"
import
{
getLatestProtocol
D
at
e
}
from
"
../../gitlab.mjs
"
import
{
getLatestProtocol
Metad
at
a
}
from
"
../../gitlab.mjs
"
const
items
=
{
all
:
null
,
...
...
@@ -29,7 +29,13 @@ const items = {
},
}
let
protocolDate
=
null
const
latestProtocol
=
{
meta
:
null
,
async
fetch
()
{
this
.
meta
=
await
getLatestProtocolMetadata
()
m
.
redraw
()
},
}
export
const
Fachschaftssitzung
=
{
oncreate
()
{
...
...
@@ -37,7 +43,7 @@ export const Fachschaftssitzung = {
},
async
oninit
()
{
items
.
fetch
()
protocolDate
=
await
getL
atestProtocol
Date
()
l
atestProtocol
.
fetch
()
},
view
()
{
return
m
(
Base
,
[
...
...
@@ -49,9 +55,7 @@ export const Fachschaftssitzung = {
m
(
"
p
"
,
m
(
ButtonAndTextLink
,
{
href
:
protocolDate
&&
`https://gitlab.cl.uni-heidelberg.de/-/ide/project/fachschaft/protokolle/edit/master/-/
${
protocolDate
.
slice
(
0
,
4
)}
/
${
protocolDate
}
.md`
,
href
:
latestProtocol
.
meta
?.
editLink
,
icon
:
"
fa-solid fa-file-pen
"
,
name
:
"
Aktuelles Protokoll bearbeiten
"
,
}),
...
...
@@ -59,23 +63,20 @@ export const Fachschaftssitzung = {
m
(
"
p
"
,
m
(
ButtonAndTextLink
,
{
href
:
protocolDate
&&
`https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/
${
protocolDate
}
.pdf?job=convert-to-pdf`
,
href
:
latestProtocol
.
meta
?.
downloadLink
,
icon
:
"
fa-regular fa-file-pdf
"
,
name
:
"
Protokoll als PDF herunterladen
"
,
}),
),
m
(
"
p
"
,
m
(
ButtonAndTextLink
,
{
href
:
protocolDate
&&
`https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/
${
protocolDate
}
_nur_Beschlüsse.pdf?job=convert-to-pdf`
,
icon
:
"
fa-solid fa-gavel
"
,
name
:
"
Beschlüsse als PDF herunterladen
"
,
}),
),
latestProtocol
.
meta
?.
containsResolution
&&
m
(
"
p
"
,
m
(
ButtonAndTextLink
,
{
href
:
latestProtocol
.
meta
?.
resolutionDownloadLink
,
icon
:
"
fa-solid fa-gavel
"
,
name
:
"
Beschlüsse als PDF herunterladen
"
,
}),
),
]),
])
},
...
...
This diff is collapsed.
Click to expand it.
portal/static/js/gitlab.mjs
+
51
−
18
View file @
5ab9f823
...
...
@@ -39,39 +39,72 @@
* the check will always fail.
*
* @param {String} imageUrl A url to an image file (likely hosted on some other origin)
* @returns The <img> object for further processing, or null if the browser cannot access it.
*/
async
function
canA
ccess
(
imageUrl
)
{
async
function
a
ccess
(
imageUrl
)
{
try
{
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
const
img
=
document
.
createElement
(
"
img
"
)
img
.
addEventListener
(
"
load
"
,
resolve
)
img
.
addEventListener
(
"
load
"
,
resolve
(
img
)
)
img
.
addEventListener
(
"
error
"
,
reject
)
img
.
src
=
imageUrl
})
return
true
}
catch
{
return
false
return
null
}
}
export
async
function
isLoggedIn
()
{}
function
toIsoString
(
year
,
month
,
day
)
{
return
`
${
year
.
toString
().
padStart
(
4
,
"
0
"
)}
-
${
month
.
toString
().
padStart
(
2
,
"
0
"
)}
-
${
day
.
toString
().
padStart
(
2
,
"
0
"
)}
`
}
/**
* @returns if the browser session has access to the protocols repo on GitLab
* Return an object with metadata about the latest protocol, or null, if the metadata cannot be accessed
* (e.g., because the user is not logged in to GitLab, is logged in but has no access to the repo, or an error occurred in the pipeline).
*
* An example metadata object would be:
* {
* year: 2024,
* month: 6,
* day: 19,
* dateIso: "2024-06-19",
* containsResolution: true,
* editLink: "https://gitlab.cl.uni-heidelberg.de/-/ide/project/fachschaft/protokolle/edit/master/-/2024/2024-06-19.md",
* downloadLink: "https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/2024-06-19.pdf?job=convert-to-pdf",
* resolutionDownloadLink: "https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/2024-06-19_nur_Beschlüsse.pdf?job=convert-to-pdf"
* }
*/
export
async
function
canAcc
es
s
Protocol
s
()
{
return
await
canA
ccess
(
export
async
function
getLat
es
t
Protocol
Metadata
()
{
const
img
=
await
a
ccess
(
"
https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/prtcl.svg?job=create-protocol-info-svg
"
,
)
}
/**
* @returns the date of the latest protocol, e.g. "2024-06-19"
*/
export
async
function
getLatestProtocolDate
()
{
// TODO Actually fetch the information from GitLab somehow
const
now
=
new
Date
()
const
today
=
now
.
toISOString
().
split
(
"
T
"
)[
0
]
if
(
!
img
)
{
return
null
}
const
year
=
img
.
width
const
month
=
Math
.
floor
(
img
.
height
/
100
)
const
dayAndMaybeOffset
=
img
.
height
-
100
*
month
const
containsResolution
=
dayAndMaybeOffset
>=
43
const
day
=
containsResolution
?
dayAndMaybeOffset
-
42
:
dayAndMaybeOffset
const
dateIso
=
toIsoString
(
year
,
month
,
day
)
return
today
const
editLink
=
`https://gitlab.cl.uni-heidelberg.de/-/ide/project/fachschaft/protokolle/edit/master/-/
${
year
}
/
${
dateIso
}
.md`
const
downloadLink
=
`https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/
${
dateIso
}
.pdf?job=convert-to-pdf`
const
resolutionDownloadLink
=
containsResolution
?
`https://gitlab.cl.uni-heidelberg.de/api/v4/projects/1193/jobs/artifacts/master/raw/pdfs/
${
dateIso
}
_nur_Beschlüsse.pdf?job=convert-to-pdf`
:
null
return
{
dateIso
,
year
,
month
,
day
,
containsResolution
,
editLink
,
downloadLink
,
resolutionDownloadLink
,
}
}
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