Skip to content

Commit

Permalink
🎨 The Publishing service no longer support export #12928
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 27, 2024
1 parent 4e407b0 commit 4a33fa9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 33 deletions.
5 changes: 4 additions & 1 deletion app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
progressBackgroundTask,
progressLoading,
progressStatus,
reloadSync, setDefRefCount, setRefDynamicText,
reloadSync,
setDefRefCount,
setRefDynamicText,
setTitle,
transactionError
} from "./dialog/processSystem";
Expand Down Expand Up @@ -166,6 +168,7 @@ export class App {
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
window.siyuan.config = response.data.conf;
window.siyuan.isPublish = response.data.isPublish;
await loadPlugins(this);
getLocalStorage(() => {
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
Expand Down
3 changes: 3 additions & 0 deletions app/src/menus/commonMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
};

export const exportMd = (id: string) => {
if (window.siyuan.isPublish) {
return;
}
return new MenuItem({
id: "export",
label: window.siyuan.languages.export,
Expand Down
1 change: 1 addition & 0 deletions app/src/mobile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class App {
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
window.siyuan.config = confResponse.data.conf;
window.siyuan.isPublish = confResponse.data.isPublish;
correctHotkey(siyuanApp);
await loadPlugins(this);
getLocalStorage(() => {
Expand Down
6 changes: 5 additions & 1 deletion app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ interface ISiyuan {
bookmarkLabel?: string[]
blockPanels: import("../block/Panel").BlockPanel[],
dialogs: import("../dialog").Dialog[],
viewer?: Viewer
viewer?: Viewer,
/**
* 是否在发布服务下访问
*/
isPublish?: boolean;
}

interface IOperation {
Expand Down
9 changes: 7 additions & 2 deletions app/src/window/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import {fetchGet, fetchPost} from "../util/fetch";
import {addBaseURL, setNoteBook} from "../util/pathName";
import {openFileById} from "../editor/util";
import {
processSync, progressBackgroundTask,
processSync,
progressBackgroundTask,
progressLoading,
progressStatus, reloadSync, setDefRefCount, setRefDynamicText,
progressStatus,
reloadSync,
setDefRefCount,
setRefDynamicText,
setTitle,
transactionError
} from "../dialog/processSystem";
Expand Down Expand Up @@ -151,6 +155,7 @@ class App {
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
window.siyuan.config = response.data.conf;
window.siyuan.isPublish = response.data.isPublish;
await loadPlugins(this);
getLocalStorage(() => {
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
Expand Down
52 changes: 26 additions & 26 deletions kernel/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/notebook/renameNotebook", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameNotebook)
ginServer.Handle("POST", "/api/notebook/changeSortNotebook", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, changeSortNotebook)
ginServer.Handle("POST", "/api/notebook/setNotebookIcon", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setNotebookIcon)
ginServer.Handle("POST", "/api/notebook/getNotebookInfo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getNotebookInfo)
ginServer.Handle("POST", "/api/notebook/getNotebookInfo", model.CheckAuth, model.CheckReadonly, getNotebookInfo)

ginServer.Handle("POST", "/api/filetree/searchDocs", model.CheckAuth, searchDocs)
ginServer.Handle("POST", "/api/filetree/listDocsByPath", model.CheckAuth, listDocsByPath)
Expand Down Expand Up @@ -276,33 +276,33 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/asset/fullReindexAssetContent", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, fullReindexAssetContent)
ginServer.Handle("POST", "/api/asset/statAsset", model.CheckAuth, model.CheckAdminRole, statAsset)

ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, batchExportMd)
ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, exportMd)
ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, exportSY)
ginServer.Handle("POST", "/api/export/exportNotebookSY", model.CheckAuth, exportNotebookSY)
ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, exportMdContent)
ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, exportHTML)
ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, exportPreviewHTML)
ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML)
ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, exportDocx)
ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, processPDF)
ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, model.CheckAdminRole, batchExportMd)
ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, model.CheckAdminRole, exportMd)
ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, model.CheckAdminRole, exportSY)
ginServer.Handle("POST", "/api/export/exportNotebookSY", model.CheckAuth, model.CheckAdminRole, exportNotebookSY)
ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, model.CheckAdminRole, exportMdContent)
ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, model.CheckAdminRole, exportHTML)
ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, model.CheckAdminRole, exportPreviewHTML)
ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, model.CheckAdminRole, exportMdHTML)
ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, model.CheckAdminRole, exportDocx)
ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, model.CheckAdminRole, processPDF)
ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview)
ginServer.Handle("POST", "/api/export/exportResources", model.CheckAuth, exportResources)
ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, exportAsFile)
ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData)
ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, exportDataInFolder)
ginServer.Handle("POST", "/api/export/exportTempContent", model.CheckAuth, exportTempContent)
ginServer.Handle("POST", "/api/export/exportResources", model.CheckAuth, model.CheckAdminRole, exportResources)
ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, model.CheckAdminRole, exportAsFile)
ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, model.CheckAdminRole, exportData)
ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, model.CheckAdminRole, exportDataInFolder)
ginServer.Handle("POST", "/api/export/exportTempContent", model.CheckAuth, model.CheckAdminRole, exportTempContent)
ginServer.Handle("POST", "/api/export/export2Liandi", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, export2Liandi)
ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, exportReStructuredText)
ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, exportAsciiDoc)
ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, exportTextile)
ginServer.Handle("POST", "/api/export/exportOPML", model.CheckAuth, exportOPML)
ginServer.Handle("POST", "/api/export/exportOrgMode", model.CheckAuth, exportOrgMode)
ginServer.Handle("POST", "/api/export/exportMediaWiki", model.CheckAuth, exportMediaWiki)
ginServer.Handle("POST", "/api/export/exportODT", model.CheckAuth, exportODT)
ginServer.Handle("POST", "/api/export/exportRTF", model.CheckAuth, exportRTF)
ginServer.Handle("POST", "/api/export/exportEPUB", model.CheckAuth, exportEPUB)
ginServer.Handle("POST", "/api/export/exportAttributeView", model.CheckAuth, exportAttributeView)
ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, model.CheckAdminRole, exportReStructuredText)
ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, model.CheckAdminRole, exportAsciiDoc)
ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, model.CheckAdminRole, exportTextile)
ginServer.Handle("POST", "/api/export/exportOPML", model.CheckAuth, model.CheckAdminRole, exportOPML)
ginServer.Handle("POST", "/api/export/exportOrgMode", model.CheckAuth, model.CheckAdminRole, exportOrgMode)
ginServer.Handle("POST", "/api/export/exportMediaWiki", model.CheckAuth, model.CheckAdminRole, exportMediaWiki)
ginServer.Handle("POST", "/api/export/exportODT", model.CheckAuth, model.CheckAdminRole, exportODT)
ginServer.Handle("POST", "/api/export/exportRTF", model.CheckAuth, model.CheckAdminRole, exportRTF)
ginServer.Handle("POST", "/api/export/exportEPUB", model.CheckAuth, model.CheckAdminRole, exportEPUB)
ginServer.Handle("POST", "/api/export/exportAttributeView", model.CheckAuth, model.CheckAdminRole, exportAttributeView)

ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importStdMd)
ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importData)
Expand Down
8 changes: 5 additions & 3 deletions kernel/api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ func getConf(c *gin.Context) {

// REF: https://github.com/siyuan-note/siyuan/issues/11364
role := model.GetGinContextRole(c)
if model.IsReadOnlyRole(role) {
isPublish := model.IsReadOnlyRole(role)
if isPublish {
maskedConf.ReadOnly = true
}
if !model.IsValidRole(role, []model.Role{
Expand All @@ -439,8 +440,9 @@ func getConf(c *gin.Context) {
}

ret.Data = map[string]interface{}{
"conf": maskedConf,
"start": !util.IsUILoaded,
"conf": maskedConf,
"start": !util.IsUILoaded,
"isPublish": isPublish,
}
}

Expand Down

0 comments on commit 4a33fa9

Please sign in to comment.