Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Trac2Gitlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Stud.IP
Plugins
Trac2Gitlab
Commits
03c36eb1
Commit
03c36eb1
authored
2 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
add link to installation documentation and increase filesize speed, fixes
#45
parent
27b9ff56
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/releases.php
+42
-25
42 additions, 25 deletions
controllers/releases.php
plugin.manifest
+1
-1
1 addition, 1 deletion
plugin.manifest
with
43 additions
and
26 deletions
controllers/releases.php
+
42
−
25
View file @
03c36eb1
...
@@ -4,6 +4,7 @@ final class ReleasesController extends \TracToGitlab\Controller
...
@@ -4,6 +4,7 @@ final class ReleasesController extends \TracToGitlab\Controller
const
CACHE_KEY
=
'studip-releases'
;
const
CACHE_KEY
=
'studip-releases'
;
private
static
$curl_handle
=
null
;
private
static
$curl_handle
=
null
;
private
$filesize_cache
;
public
function
before_filter
(
&
$action
,
&
$args
)
public
function
before_filter
(
&
$action
,
&
$args
)
{
{
...
@@ -26,7 +27,18 @@ final class ReleasesController extends \TracToGitlab\Controller
...
@@ -26,7 +27,18 @@ final class ReleasesController extends \TracToGitlab\Controller
Icon
::
create
(
'link2'
),
Icon
::
create
(
'link2'
),
[
'target'
=>
'_blank'
]
[
'target'
=>
'_blank'
]
);
);
$widget
->
addLink
(
_
(
'Installationsanleitung'
),
'https://hilfe.studip.de/admin/Admins/Installationsanleitung'
,
Icon
::
create
(
'rescue'
),
[
'target'
=>
'_blank'
]
);
Sidebar
::
get
()
->
addWidget
(
$widget
);
Sidebar
::
get
()
->
addWidget
(
$widget
);
$this
->
filesize_cache
=
new
StudipCachedArray
(
self
::
CACHE_KEY
.
'/filesizes'
,
strtotime
(
'+10 years'
)
);
}
}
public
function
after_filter
(
$action
,
$args
)
public
function
after_filter
(
$action
,
$args
)
...
@@ -40,7 +52,7 @@ final class ReleasesController extends \TracToGitlab\Controller
...
@@ -40,7 +52,7 @@ final class ReleasesController extends \TracToGitlab\Controller
public
function
index_action
()
public
function
index_action
()
{
{
$version
=
Request
::
get
(
'version'
);
$version
=
Request
::
get
(
'version'
,
Request
::
get
(
'v'
)
);
$this
->
releases
=
$this
->
getReleases
();
$this
->
releases
=
$this
->
getReleases
();
...
@@ -58,6 +70,7 @@ final class ReleasesController extends \TracToGitlab\Controller
...
@@ -58,6 +70,7 @@ final class ReleasesController extends \TracToGitlab\Controller
{
{
if
(
$this
->
isAdmin
())
{
if
(
$this
->
isAdmin
())
{
StudipCacheFactory
::
getCache
()
->
expire
(
self
::
CACHE_KEY
);
StudipCacheFactory
::
getCache
()
->
expire
(
self
::
CACHE_KEY
);
$this
->
filesize_cache
->
expire
();
}
}
$this
->
relocate
(
$this
->
indexURL
());
$this
->
relocate
(
$this
->
indexURL
());
...
@@ -159,37 +172,41 @@ final class ReleasesController extends \TracToGitlab\Controller
...
@@ -159,37 +172,41 @@ final class ReleasesController extends \TracToGitlab\Controller
return
$hardcoded_size
;
return
$hardcoded_size
;
}
}
// Init curl if necessary
if
(
!
isset
(
$this
->
filesize_cache
[
$url
]))
{
if
(
self
::
$curl_handle
===
null
)
{
// Init curl if necessary
self
::
$curl_handle
=
curl_init
(
null
);
if
(
self
::
$curl_handle
===
null
)
{
self
::
$curl_handle
=
curl_init
(
null
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_HEADER
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_HEADER
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_NOBODY
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_NOBODY
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_FOLLOWLOCATION
,
true
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_FOLLOWLOCATION
,
true
);
}
}
// Set url and send request
// Set url and send request
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_URL
,
$url
);
curl_setopt
(
self
::
$curl_handle
,
CURLOPT_URL
,
$url
);
$response
=
curl_exec
(
self
::
$curl_handle
);
$response
=
curl_exec
(
self
::
$curl_handle
);
// Get status
// Get status
$line
=
strtok
(
$response
,
"
\r\n
"
);
$line
=
strtok
(
$response
,
"
\r\n
"
);
$status
=
trim
(
$line
);
$status
=
trim
(
$line
);
// Parse headers
// Parse headers
$headers
=
[];
$headers
=
[];
while
((
$line
=
strtok
(
"
\r\n
"
))
!==
false
)
{
while
((
$line
=
strtok
(
"
\r\n
"
))
!==
false
)
{
$chunks
=
explode
(
':'
,
$line
,
2
);
$chunks
=
explode
(
':'
,
$line
,
2
);
if
(
$chunks
!==
false
&&
count
(
$chunks
)
===
2
)
{
if
(
$chunks
!==
false
&&
count
(
$chunks
)
===
2
)
{
$headers
[
$chunks
[
0
]]
=
$chunks
[
1
];
$headers
[
$chunks
[
0
]]
=
$chunks
[
1
];
}
}
}
}
// TODO: Check status
// TODO: Check status
// Get filesize by Content-Length header
$this
->
filesize_cache
[
$url
]
=
(
int
)
(
$headers
[
'Content-Length'
]
??
-
1
);
}
// Get filesize by Content-Length header
return
$this
->
filesize_cache
[
$url
];
return
(
int
)
(
$headers
[
'Content-Length'
]
??
-
1
);
}
}
private
function
addVersionFilter
(
array
$releases
,
?string
$version
):
void
private
function
addVersionFilter
(
array
$releases
,
?string
$version
):
void
...
...
This diff is collapsed.
Click to expand it.
plugin.manifest
+
1
−
1
View file @
03c36eb1
...
@@ -2,5 +2,5 @@ pluginname=Trac to gitlab converter
...
@@ -2,5 +2,5 @@ pluginname=Trac to gitlab converter
pluginclassname=TracToGitlabPlugin
pluginclassname=TracToGitlabPlugin
pluginclassname=StudipReleasesPlugin
pluginclassname=StudipReleasesPlugin
origin=UOL
origin=UOL
version=1.4.
2
version=1.4.
3
studipMinVersion=5.0
studipMinVersion=5.0
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