Fix critical enhancement hanging bug caused by nil context in content injection
Replace nil context with context.Background() in content.go to prevent database operations from hanging indefinitely. Clean up outdated documentation files and add current project structure analysis.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
@@ -18,8 +19,8 @@ func (e *ContentEngine) injectContent(elements []ProcessedElement, siteID string
|
||||
for i := range elements {
|
||||
elem := &elements[i]
|
||||
|
||||
// Get content from database by ID
|
||||
contentItem, err := e.client.GetContent(nil, siteID, elem.ID)
|
||||
// Get content from database by ID - FIXED: Use context.Background() instead of nil
|
||||
contentItem, err := e.client.GetContent(context.Background(), siteID, elem.ID)
|
||||
if err != nil {
|
||||
// Content not found - skip silently (enhancement mode should not fail on missing content)
|
||||
continue
|
||||
|
||||
@@ -30,7 +30,25 @@ func (e *ContentEngine) discoverElements(doc *html.Node) ([]InsertrElement, []Co
|
||||
// Walk the document and categorize elements
|
||||
e.walkNodes(doc, func(n *html.Node) {
|
||||
if n.Type == html.ElementNode {
|
||||
if hasInsertrClass(n) {
|
||||
if e.hasInsertrAddClass(n) {
|
||||
// Collection element
|
||||
if hasInsertrClass(n) {
|
||||
// Handle .insertr.insertr-add combination:
|
||||
// Remove .insertr from container, add .insertr to viable children
|
||||
RemoveClass(n, "insertr")
|
||||
viableChildren := FindViableChildren(n)
|
||||
for _, child := range viableChildren {
|
||||
if !hasInsertrClass(child) {
|
||||
AddClass(child, "insertr")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add as collection (collections take precedence)
|
||||
collectionElements = append(collectionElements, CollectionElement{
|
||||
Node: n,
|
||||
})
|
||||
} else if hasInsertrClass(n) {
|
||||
// Regular insertr element (only if not a collection)
|
||||
if isContainer(n) {
|
||||
// Container element - mark for transformation
|
||||
containersToTransform = append(containersToTransform, n)
|
||||
@@ -41,12 +59,6 @@ func (e *ContentEngine) discoverElements(doc *html.Node) ([]InsertrElement, []Co
|
||||
})
|
||||
}
|
||||
}
|
||||
if e.hasInsertrAddClass(n) {
|
||||
// Collection element - add directly (no container transformation for collections)
|
||||
collectionElements = append(collectionElements, CollectionElement{
|
||||
Node: n,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user