Skip to content

Commit dca38fe

Browse files
updates
1 parent 692dcfc commit dca38fe

File tree

5 files changed

+84
-13
lines changed

5 files changed

+84
-13
lines changed

src/documentation/customcss.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
3+
MIT License
4+
5+
Copyright (c) 2025 JustStudio. <https://juststudio.is-a.dev/>
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
25+
*/
26+
27+
const baseregex = /(@_just base)/g;
28+
const baseregex2= /(@_just base;)/g;
29+
exports.customcss = function (CSS, CUSTOM) {
30+
if (!CUSTOM) {
31+
return CSS
32+
}
33+
CUSTOM = CUSTOM
34+
.replace(baseregex2,CSS)
35+
.replace(baseregex, CSS)
36+
return CUSTOM
37+
}

src/documentation/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ SOFTWARE.
2525
*/
2626

2727
const _just = {};
28-
const [HTMLtemplate, CSStemplate, JStemplate, PATH, repo, owner] = process.argv.slice(2);
28+
const [HTMLtemplate, CSStemplate, JStemplate, PATH, repo, owner, customCSS] = process.argv.slice(2);
2929
let HTML = HTMLtemplate;
3030
let CSS = CSStemplate;
3131
let JS = JStemplate;
3232
_just.string = require('../modules/string.js');
3333
_just.element = (type, insert) => `<_just${type ? ` element="${type}"` : ''}>${insert || ''}</_just>`;
3434
_just.error = require('../modules/errmsg.js');
3535
_just.ssapi = require('../modules/ssapi.js');
36+
_just.customCSS = require('./customcss.js').customcss;
3637

3738
const link = (text, link_, ext = false, extid = "ext", target = "_blank") => `<a href="${link_}" target="${target}"${ext ? ` id="${extid}"` : ''}>${text}</a>`;
3839
const span = (text) => `<span>${text}</span>`;
@@ -764,14 +765,22 @@ markdownFiles.forEach(file => {
764765
logs += `${l[2]}OUTPUT: ${_just.string.runnerPath(outFilePath('html'))} (${_just.string.fileSize(fs.statSync(outFilePath('html')).size)})`;
765766
});
766767

768+
CSS = _just.customCSS(CSS, customCSS == 'false' ? undefined : customCSS);
769+
767770
logs += linklogs; logs += buttonlogs;
768771
logs += `${l[0]}USED NAMES:${l[1]}"${uniqueNames_.join('", "')}"${l[0]}DATA NAMES:${l[1]}"${dataname.join('", "')}"`;
769772
console.log('\n\n\n\n\n'+logs);
770-
fs.writeFileSync(path.join(rootDirA !== '.' ? rootDirA : rootDirB, '_just_data', 'output.txt'), logs, template.charset);
771-
fs.writeFileSync(path.join(rootDirA !== '.' ? rootDirA : rootDirB, '_just', `${filename.css}.css`), CSS, template.charset);
773+
const websitepath = rootDirA !== '.' ? rootDirA : rootDirB;
774+
fs.writeFileSync(path.join(websitepath, '_just_data', 'output.txt'), logs, template.charset);
775+
fs.writeFileSync(path.join(websitepath, '_just', `${filename.css}.css`), CSS, template.charset);
772776
fs.writeFileSync(
773-
path.join(rootDirA !== '.' ? rootDirA : rootDirB, '_just', `${filename.js}.js`),
774-
JS.replace('\'PUBLICOUTPUT\'', publicOutput).replace('fetch("/_just/search")', `fetch("/_just/${dataname[9]}.json")`),
777+
path.join(websitepath, '_just', `${filename.js}.js`),
778+
JS.replace('\'PUBLICOUTPUT\'', publicOutput).replace('let searchurl = "/_just/search";', `let searchurl = "/_just/${dataname[9]}.json";`),
775779
template.charset
776780
);
777-
fs.writeFileSync(path.join(rootDirA !== '.' ? rootDirA : rootDirB, '_just', `${dataname[9]}.json`), JSON.stringify(mdjson), template.charset);
781+
fs.writeFileSync(path.join(websitepath, '_just', `${dataname[9]}.json`), JSON.stringify(mdjson), template.charset);
782+
fs.writeFileSync(path.join(websitepath, '_just', '404.json'), JSON.stringify({
783+
"js": filename.js,
784+
"css": filename.css,
785+
"json": dataname[9]
786+
}), template.charset)

src/documentation/templates/page.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ h1, h2, h3 {
933933

934934
.search {
935935
position: fixed;
936-
padding-top: 6px;
936+
padding-top: 16px;
937937
padding-left: 7px;
938938
padding-right: 7px;
939939
padding-bottom: 6px;
@@ -944,9 +944,10 @@ h1, h2, h3 {
944944
align-content: flex-start;
945945
align-items: flex-start;
946946
justify-content: flex-start;
947+
gap: 10px;
947948
background-color: var(--md);
948-
backdrop-filter: blur(4px) url("#glass-distortion") brightness(0.3);
949-
-webkit-backdrop-filter: blur(4px) url("#glass-distortion") brightness(0.3);
949+
backdrop-filter: blur(4px) url("#glass") brightness(0.3);
950+
-webkit-backdrop-filter: blur(4px) url("#glass") brightness(0.3);
950951
z-index: -1;
951952
border-bottom-left-radius: 10px;
952953
border-bottom-right-radius: 10px;

src/documentation/templates/page.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,37 @@ document.addEventListener('DOMContentLoaded', () => {
264264
}
265265
return true;
266266
};
267+
let searchurl = "/_just/search";
267268
sb.addEventListener("input", async () => {
268269
const sv = sb.value;
269270
const st = searchString(sv);
270271
sd.innerHTML = '<span>Loading...</span>';
271272
updateSD(st);
273+
const pta = '<br>Please try again';
272274
if (st) {
273-
const response = await fetch("/_just/search").catch((err__)=>{
275+
let response = await fetch(searchurl).catch((err__)=>{
274276
console.warn(err__);
275-
sd.innerHTML = '<span>Failed to fetch.<br>Please try again</span>';
277+
sd.innerHTML = `<span>Failed to fetch.${pta}</span>`;
276278
return
277279
});
278-
const data = await response.json();
280+
let data = await response.json().catch((err__)=>{
281+
console.warn(err__);
282+
sd.innerHTML = `<span>Something went wrong.${pta}</span>`;
283+
return
284+
});
285+
if (data.json) {
286+
searchurl = data.json;
287+
response = await fetch(searchurl).catch((err__)=>{
288+
console.warn(err__);
289+
sd.innerHTML = `<span>Failed to fetch.${pta}</span>`;
290+
return
291+
});
292+
data = await response.json().catch((err__)=>{
293+
console.warn(err__);
294+
sd.innerHTML = `<span>Something went wrong.${pta}</span>`;
295+
return
296+
});
297+
}
279298
const searchdata = search2(data, sv);
280299
if (searchdata.length == 0) {
281300
sd.innerHTML = '<span>Nothing found.</span>';

src/run.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ elif [ "$TYPE" == "generator" ]; then
150150
HTML=$(cat "$GITHUB_ACTION_PATH/src/documentation/templates/page.html")
151151
CSS=$(cat "$GITHUB_ACTION_PATH/src/documentation/templates/page.css")
152152
JS=$(cat "$GITHUB_ACTION_PATH/src/documentation/templates/page.js")
153+
CUSTOMCSS=false
154+
CUSTOMCSSPATH="just.config.css"
155+
if [ -f "$CUSTOMCSSPATH" ]; then
156+
CUSTOMCSS=$(cat "$CUSTOMCSSPATH")
157+
fi
153158
if [[ -d "_just" && "$_just_d" == "no" ]]; then
154159
local ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0121")
155160
echo "$ERROR_MESSAGE" && exit 1
@@ -158,7 +163,7 @@ elif [ "$TYPE" == "generator" ]; then
158163
mkdir -p deploy && \
159164
installNodejs && \
160165
bash $GITHUB_ACTION_PATH/src/documentation/checks.sh && \
161-
node "$GITHUB_ACTION_PATH/src/documentation/index.js" "$HTML" "$CSS" "$JS" "$INPUT_PATH" "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" && \
166+
node "$GITHUB_ACTION_PATH/src/documentation/index.js" "$HTML" "$CSS" "$JS" "$INPUT_PATH" "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" "$CUSTOMCSS" && \
162167
node $GITHUB_ACTION_PATH/src/compress.js "$INPUT_PATH" && \
163168
node "$GITHUB_ACTION_PATH/src/documentation/logs.js" "$INPUT_PATH" && \
164169
echo "$msg9"

0 commit comments

Comments
 (0)