Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
webv4
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Main
webv4
Commits
0c2ba261
Commit
0c2ba261
authored
6 years ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Change how settings are validated and defaults are applied.
parent
6e5535f5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/lib/init.js
+43
-44
43 additions, 44 deletions
web/lib/init.js
with
43 additions
and
44 deletions
web/lib/init.js
+
43
−
44
View file @
0c2ba261
load
(
'
sbbsdefs.js
'
);
load
(
'
modopts.js
'
);
load
(
'
modopts.js
'
);
var
settings
=
get_mod_options
(
'
web
'
);
var
settings
=
get_mod_options
(
'
web
'
);
...
@@ -22,48 +23,46 @@ settings.web_lib = backslash(settings.web_directory + 'lib/');
...
@@ -22,48 +23,46 @@ settings.web_lib = backslash(settings.web_directory + 'lib/');
settings
.
web_pages
=
backslash
(
fullpath
(
settings
.
web_root
+
'
../pages
'
));
settings
.
web_pages
=
backslash
(
fullpath
(
settings
.
web_root
+
'
../pages
'
));
settings
.
web_sidebar
=
backslash
(
fullpath
(
settings
.
web_root
+
'
../sidebar
'
));
settings
.
web_sidebar
=
backslash
(
fullpath
(
settings
.
web_root
+
'
../sidebar
'
));
// Guest
var
defaults
=
{
if
(
typeof
settings
.
guest
===
'
undefined
'
)
settings
.
guest
=
'
Guest
'
;
guest
:
{
if
(
system
.
matchuser
(
settings
.
guest
)
==
0
)
exit
();
default
:
'
Guest
'
,
test
:
function
()
{
// Timeout
return
system
.
matchuser
(
settings
.
guest
)
?
null
:
'
Guest account unavailable
'
;
if
(
typeof
settings
.
timeout
!==
'
number
'
)
settings
.
timeout
=
43200
;
// Registration
if
(
typeof
settings
.
user_registration
!==
'
boolean
'
)
{
settings
.
user_registration
=
false
;
}
else
{
if
(
typeof
settings
.
minimum_password_length
!==
'
number
'
)
{
settings
.
minimum_password_length
=
4
;
}
if
(
typeof
settings
.
email_validation
!==
'
boolean
'
)
{
settings
.
email_validation
=
true
;
}
if
(
typeof
settings
.
email_validation_level
!==
'
number
'
)
{
settings
.
email_validation_level
=
50
;
}
}
},
}
timeout
:
{
default
:
43200
},
user_registration
:
{
default
:
false
},
if
(
typeof
settings
.
max_messages
!==
'
number
'
||
settings
.
max_messages
<
0
)
{
minimum_password_length
:
{
default
:
4
},
settings
.
max_messages
=
0
;
email_validation
:
{
default
:
true
},
email_validation_level
:
{
default
:
50
},
max_messages
:
{
default
:
0
,
test
:
function
()
{
return
settings
.
max_messages
>=
0
?
null
:
'
max_messages must be >= 0
'
;
}
}
},
if
(
typeof
settings
.
page_size
!==
'
number
'
||
settings
.
page_size
<
1
)
{
page_size
:
{
settings
.
page_size
=
25
;
default
:
25
,
test
:
function
()
{
return
settings
.
page_size
>=
1
?
null
:
'
page_size must be >= 1
'
;
}
}
},
forum_extended_ascii
:
{
default
:
true
},
active_node_list
:
{
default
:
true
},
hide_empty_stats
:
{
default
:
true
}
};
if
(
typeof
settings
.
forum_extended_ascii
!==
'
boolean
'
)
{
Object
.
keys
(
defaults
).
forEach
(
function
(
e
)
{
settings
.
forum_extended_ascii
=
true
;
if
(
typeof
settings
[
e
]
==
'
undefined
'
)
{
settings
[
e
]
=
defaults
[
e
].
default
;
}
else
if
(
typeof
settings
[
e
]
!=
typeof
defaults
[
e
].
default
)
{
log
(
LOG_ERROR
,
'
Invalid
'
+
e
+
'
setting:
'
+
settings
[
e
]);
exit
();
}
else
if
(
typeof
defaults
[
e
].
test
==
'
function
'
)
{
const
t
=
defaults
[
e
].
test
();
if
(
t
!==
null
)
{
log
(
LOG_ERROR
,
t
);
exit
();
}
}
if
(
typeof
settings
.
active_node_list
!==
'
boolean
'
)
{
settings
.
active_node_list
=
true
;
}
if
(
typeof
settings
.
hide_empty_stats
!==
'
boolean
'
)
{
settings
.
hide_empty_stats
=
true
;
}
}
});
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