Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Main
Synchronet
Commits
1ffcbc5e
Commit
1ffcbc5e
authored
4 years ago
by
Rob Swindell
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.synchro.net:sbbs/sbbs
parents
a5cb0929
3ca57bec
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#311
passed
4 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
webv4/lib/files.js
+16
-12
16 additions, 12 deletions
webv4/lib/files.js
webv4/pages/002-files.xjs
+22
-13
22 additions, 13 deletions
webv4/pages/002-files.xjs
webv4/root/api/files.ssjs
+1
-0
1 addition, 0 deletions
webv4/root/api/files.ssjs
with
39 additions
and
25 deletions
webv4/lib/files.js
+
16
−
12
View file @
1ffcbc5e
...
...
@@ -2,26 +2,30 @@ require('filebase.js', 'FileBase');
require
(
'
file_size.js
'
,
'
file_size_str
'
);
function
count_files
(
dir
)
{
var
n
=
0
;
const
fn
=
format
(
"
%s%s.ixb
"
,
file_area
.
dir
[
dir
].
data_dir
,
dir
);
if
(
!
file_exists
(
fn
))
return
n
;
if
(
!
file_exists
(
fn
))
return
0
;
return
Math
.
floor
(
file_size
(
fn
)
/
22
);
// ixb record length is 22 bytes
}
function
li
stLibraries
(
)
{
return
file_area
.
lib_list
.
filter
(
function
(
library
)
{
return
library
.
dir_list
.
length
>=
1
;
function
li
bHasFiles
(
lib
)
{
return
lib
.
dir_list
.
some
(
function
(
e
)
{
return
count_files
(
e
.
code
)
>
0
;
});
}
function
listDirectories
(
library
)
{
var
dirs
=
[];
file_area
.
lib_list
[
library
].
dir_list
.
forEach
(
function
(
dir
)
{
const
fc
=
count_files
(
dir
.
code
);
if
(
fc
<
1
)
return
;
dirs
.
push
({
dir
:
dir
,
fileCount
:
fc
});
function
listLibraries
()
{
return
file_area
.
lib_list
.
filter
(
function
(
lib
)
{
return
lib
.
dir_list
.
length
>=
1
&&
libHasFiles
(
lib
);
});
return
dirs
;
}
function
listDirectories
(
lib
)
{
return
file_area
.
lib_list
[
lib
].
dir_list
.
reduce
(
function
(
a
,
c
)
{
const
fc
=
count_files
(
c
.
code
);
if
(
fc
<
1
)
return
a
;
a
.
push
({
dir
:
c
,
fileCount
:
fc
});
return
a
;
},
[]);
}
function
listFiles
(
dir
)
{
...
...
This diff is collapsed.
Click to expand it.
webv4/pages/002-files.xjs
+
22
−
13
View file @
1ffcbc5e
...
...
@@ -24,8 +24,13 @@
</li>
</ol>
<?xjs function writeFileDetails(file) { ?>
<? function writeFileDetails(file) { ?>
<? const cd = file_area.dir[Request.get_param('dir')].can_download && user.compare_ars(file_area.dir[Request.get_param('dir')].download_ars); ?>
<? if (cd) { ?>
<a href="./api/files.ssjs?call=download-file&dir=<? Request.write_param('dir'); ?>&file=<? write(file.name); ?>" target="_blank" class="list-group-item striped" data-file-list-element data-size="<? write(file._size); ?>" data-uploaded="<? write(file.uldate); ?>" data-name="<? write(file.name); ?>">
<? } else { ?>
<li class="list-group-item striped" data-file-list-element data-size="<? write(file._size); ?>" data-uploaded="<? write(file.uldate); ?>" data-name="<? write(file.name); ?>">
<? } ?>
<strong><? write(file.name); ?></strong> (<? write(file.size); ?>)
<p><em>Uploaded <? write(system.timestr(file.uldate)); ?></em></p>
<?xjs if (typeof file.extdesc === 'undefined') { ?>
...
...
@@ -35,8 +40,12 @@
<?xjs } else { ?>
<pre class="list"><? write(file.extdesc.replace(/[^\r,\n\x20-\x7E]/g, '')); ?></pre>
<?xjs } ?>
<? if (cd) { ?>
</a>
<?xjs } ?>
<? } else { ?>
</li>
<? } ?>
<? } ?>
<div class="clearfix" style="margin-bottom:1em;">
<div class="dropdown pull-right">
...
...
This diff is collapsed.
Click to expand it.
webv4/root/api/files.ssjs
+
1
−
0
View file @
1ffcbc5e
...
...
@@ -20,6 +20,7 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') &&
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
index
>=
0
&&
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
can_download
&&
typeof
http_request
.
query
.
file
!==
'
undefined
'
&&
user
.
compare_ars
(
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
download_ars
)
)
{
var
dircode
=
file_area
.
dir
[
http_request
.
query
.
dir
[
0
]].
code
;
var
fileBase
=
new
FileBase
(
dircode
);
...
...
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