fix-2591
into V20220815
1 year ago
@@ -133,16 +133,79 @@ function submitDeleteForm() { | |||||
$("#delete-file-form").submit() | $("#delete-file-form").submit() | ||||
} | } | ||||
} | } | ||||
const baseUrls = {}; | |||||
const justDomain = /^[^:]+:\/*[^/]*$/; | |||||
const protocol = /^([^:]+:)[\s\S]*$/; | |||||
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/; | |||||
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i; | |||||
function rtrim(str, c, invert) { | |||||
const l = str.length; | |||||
if (l === 0) { | |||||
return ''; | |||||
} | |||||
let suffLen = 0; | |||||
while (suffLen < l) { | |||||
const currChar = str.charAt(l - suffLen - 1); | |||||
if (currChar === c && !invert) { | |||||
suffLen++; | |||||
} else if (currChar !== c && invert) { | |||||
suffLen++; | |||||
} else { | |||||
break; | |||||
} | |||||
} | |||||
return str.slice(0, l - suffLen); | |||||
} | |||||
function resolveUrl(base, href) { | |||||
if (!baseUrls[' ' + base]) { | |||||
if (justDomain.test(base)) { | |||||
baseUrls[' ' + base] = base + '/'; | |||||
} else { | |||||
baseUrls[' ' + base] = rtrim(base, '/', true); | |||||
} | |||||
} | |||||
base = baseUrls[' ' + base]; | |||||
const relativeBase = base.indexOf(':') === -1; | |||||
if (href.substring(0, 2) === '//') { | |||||
if (relativeBase) { | |||||
return href; | |||||
} | |||||
return base.replace(protocol, '$1') + href; | |||||
} else if (href.charAt(0) === '/') { | |||||
if (relativeBase) { | |||||
return href; | |||||
} | |||||
return base.replace(domain, '$1') + href; | |||||
} else { | |||||
return base + href; | |||||
} | |||||
} | |||||
function showNoteBook(){ | function showNoteBook(){ | ||||
var isNoteBook = {{.IsNoteBook}} | |||||
var isNoteBook = {{.IsNoteBook}}; | |||||
if (isNoteBook) { | if (isNoteBook) { | ||||
var jsonStr = "{{.FileContent}}" | |||||
var jsonStr = "{{.FileContent}}"; | |||||
var baseUrl={{.FileParentURL}}; | |||||
nb.markdown.setOptions({ | nb.markdown.setOptions({ | ||||
baseUrl: {{.FileParentURL}} | |||||
baseUrl: baseUrl | |||||
}); | }); | ||||
var notebook = nb.parse(JSON.parse(jsonStr)); | var notebook = nb.parse(JSON.parse(jsonStr)); | ||||
var rendered = notebook.render(); | var rendered = notebook.render(); | ||||
$("#notebook").append(rendered); | $("#notebook").append(rendered); | ||||
$("#notebook img").each(function(){ | |||||
var oldSrc = $(this).attr('src'); | |||||
if (!originIndependentUrl.test(oldSrc)){ | |||||
var newSrc=resolveUrl(baseUrl,oldSrc); | |||||
$(this).attr('src', newSrc); | |||||
} | |||||
}); | |||||
Prism.highlightAll(); | Prism.highlightAll(); | ||||
} | } | ||||
} | } | ||||
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》