|
@@ -54,12 +54,28 @@ type EmbedBlock struct {
|
|
|
BlockPaths []*BlockPath `json:"blockPaths"`
|
|
|
}
|
|
|
|
|
|
+func GetEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
|
|
+ return getEmbedBlock(embedBlockID, includeIDs, headingMode, breadcrumb)
|
|
|
+}
|
|
|
+
|
|
|
+func getEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
|
|
+ stmt := "SELECT * FROM `blocks` WHERE `id` IN ('" + strings.Join(includeIDs, "','") + "')"
|
|
|
+ sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 1024)
|
|
|
+ ret = buildEmbedBlock(embedBlockID, []string{}, headingMode, breadcrumb, sqlBlocks)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func SearchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
|
|
return searchEmbedBlock(embedBlockID, stmt, excludeIDs, headingMode, breadcrumb)
|
|
|
}
|
|
|
|
|
|
func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
|
|
sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
|
|
|
+ ret = buildEmbedBlock(embedBlockID, excludeIDs, headingMode, breadcrumb, sqlBlocks)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func buildEmbedBlock(embedBlockID string, excludeIDs []string, headingMode int, breadcrumb bool, sqlBlocks []*sql.Block) (ret []*EmbedBlock) {
|
|
|
var tmp []*sql.Block
|
|
|
for _, b := range sqlBlocks {
|
|
|
if "query_embed" == b.Type { // 嵌入块不再嵌入
|
|
@@ -91,7 +107,7 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
|
|
}
|
|
|
|
|
|
for _, sb := range sqlBlocks {
|
|
|
- block, blockPaths := getEmbeddedBlock(embedBlockID, trees, sb, headingMode, breadcrumb)
|
|
|
+ block, blockPaths := getEmbeddedBlock(trees, sb, headingMode, breadcrumb)
|
|
|
if nil == block {
|
|
|
continue
|
|
|
}
|