refactor: remove dead code across server, templ pages, and client modules
Deadcode-verified removals (RTA reachability from main, cross-checked with -test and textual xrefs): Go server: - whole files: middleware/transaction.go, middleware/error_handler.go, middleware/password_validator.go (live registration machinery kept), handlers/sync.go, sync/offline.go - unrouted endpoints: auth UpdateUsername/UpdateEmail, timezone settings handler, OPDS RegisterOPDS, Kobo LibrarySync handler, ReaderHandler.ShowReader, JSON-data twins on collections/library - duplicate book-matching handlers (book_matching.go Handler twins, matching.go MatchingHandler twins), superseded helpers (router.parseUUID, handlers.ValidateDeviceToken, normalizePath, userExists, generateLockID) Templ/client: - never-routed pages: api_explorer.templ, queue.templ and their client modules api-explorer.ts, api-explorer-docs.ts, queue.ts - fully orphaned wrapper modules events.ts, dom.ts - broken clearSyncQueue (called a nonexistent endpoint) and the hidden, never-populated sync-queue section on the devices page - 166+ unused exports demoted to private (knip-verified); ~85 truly dead declarations removed via tsc noUnusedLocals fixpoint - stale 'interactive API Explorer' claims dropped from docs The docs drift-gate package (internal/docs), templ-bound modules (dashboard, stats, header, index, login, profile*, bookshelf, collections, toast-error), sqlc-generated code, and web/static are intentionally untouched.
This commit is contained in:
1 parent
8733e83f1f
commit
8631aa00bf
107 files changed
+689
-3443
No files matched your search
@@ -967,45 +967,6 @@ func findNodeAtCharOffset(root *html.Node, targetOffset int) (*html.Node, int) {
|
||||
return found, currentOffset
|
||||
}
|
||||
|
||||
func (c *CFIConverter) computePercentage(xp *CREXPointer, target *html.Node, remainingOffset int) float64 {
|
||||
spine, err := c.loadSpine()
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
|
||||
charOffset := 0
|
||||
for i := 1; i < xp.FragmentIndex; i++ {
|
||||
doc, _, err := c.getContentDoc(i)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
body := findBody(doc)
|
||||
if body != nil {
|
||||
charOffset += countTextChars(body)
|
||||
}
|
||||
}
|
||||
|
||||
charOffset += countTextCharsBefore(target)
|
||||
charOffset += remainingOffset
|
||||
|
||||
totalChars := int64(0)
|
||||
for i := range spine.items {
|
||||
doc, _, err := c.getContentDoc(i + 1)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
body := findBody(doc)
|
||||
if body != nil {
|
||||
totalChars += int64(countTextChars(body))
|
||||
}
|
||||
}
|
||||
|
||||
if totalChars <= 0 {
|
||||
return -1
|
||||
}
|
||||
return float64(charOffset) / float64(totalChars)
|
||||
}
|
||||
|
||||
type indexedNode struct {
|
||||
node *html.Node
|
||||
textChunk []*html.Node
|
||||
@@ -1157,7 +1118,6 @@ func findTextChunk(parent *html.Node, textNode *html.Node) (int, int, string) {
|
||||
return -1, 0, ""
|
||||
}
|
||||
|
||||
|
||||
func findElementCFIIndex(parent *html.Node, element *html.Node) int {
|
||||
indexed := indexChildNodes(parent)
|
||||
for i, node := range indexed {
|
||||
|
||||
@@ -11,8 +11,8 @@ package sync
|
||||
// cfi_verify_manual_test.go.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -7,8 +7,10 @@ import (
|
||||
|
||||
// The fixture (writeTestEPUB in cfi_converter_test.go): 6 spine docs.
|
||||
// doc2 = spine index 1 with two paragraphs:
|
||||
// p1: "The family of Dashwood had long been settled in Sussex."
|
||||
// p2: "Their estate was large, and their residence was at Norland Park."
|
||||
//
|
||||
// p1: "The family of Dashwood had long been settled in Sussex."
|
||||
// p2: "Their estate was large, and their residence was at Norland Park."
|
||||
//
|
||||
// Hand-derived local paths (html→body /4, body→div /4, div→p /4|/6,
|
||||
// p→text chunk /1):
|
||||
const (
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
@@ -13,10 +12,10 @@ type KEPUBCFIConverter struct {
|
||||
}
|
||||
|
||||
type KEPUBConversionResult struct {
|
||||
CFI string
|
||||
ExtractedContext string
|
||||
Percentage float64
|
||||
Precision string
|
||||
CFI string
|
||||
ExtractedContext string
|
||||
Percentage float64
|
||||
Precision string
|
||||
}
|
||||
|
||||
func NewKEPUBCFIConverter(epubPath, kepubPath string) *KEPUBCFIConverter {
|
||||
@@ -265,57 +264,6 @@ func extractSurroundingText(textNode *html.Node, offset int, window int) string
|
||||
return normalizeWhitespace(string(allRunes[start:end]))
|
||||
}
|
||||
|
||||
func (k *KEPUBCFIConverter) ComputeKEPUBPercentage(kepubCFI string) (float64, error) {
|
||||
if !IsStandardEPUBCFI(kepubCFI) {
|
||||
return -1, fmt.Errorf("not a standard epubcfi")
|
||||
}
|
||||
|
||||
spineIndex, steps, err := parseEPUBCFI(kepubCFI)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
kepubDoc, _, docErr := k.kepubConverter.getContentDoc(spineIndex + 1)
|
||||
if docErr != nil {
|
||||
return -1, docErr
|
||||
}
|
||||
|
||||
kepubBody := findBody(kepubDoc)
|
||||
if kepubBody == nil {
|
||||
return -1, fmt.Errorf("no body in kepub doc")
|
||||
}
|
||||
|
||||
textNode, textOffset, resolveErr := resolveCFIToNode(kepubBody, steps)
|
||||
if resolveErr != nil {
|
||||
return -1, resolveErr
|
||||
}
|
||||
|
||||
charOffset := countTextCharsBefore(textNode) + textOffset
|
||||
|
||||
total := 0
|
||||
kepubSpine, spineErr := k.kepubConverter.loadSpine()
|
||||
if spineErr != nil {
|
||||
return -1, spineErr
|
||||
}
|
||||
|
||||
for i := range kepubSpine.items {
|
||||
doc, _, dErr := k.kepubConverter.getContentDoc(i + 1)
|
||||
if dErr != nil {
|
||||
continue
|
||||
}
|
||||
b := findBody(doc)
|
||||
if b != nil {
|
||||
total += countTextChars(b)
|
||||
}
|
||||
}
|
||||
|
||||
if total <= 0 {
|
||||
return -1, fmt.Errorf("no text in kepub")
|
||||
}
|
||||
|
||||
return float64(charOffset) / float64(total), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
_ = log.Printf
|
||||
}
|
||||
@@ -260,21 +260,6 @@ func FormatProgressForDisplay(formatGroup FormatGroup, progress map[string]inter
|
||||
}
|
||||
}
|
||||
|
||||
// ParseProgressFromJSON parses progress data from JSON
|
||||
func ParseProgressFromJSON(data []byte) (*ProgressData, error) {
|
||||
var progress ProgressData
|
||||
err := json.Unmarshal(data, &progress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &progress, nil
|
||||
}
|
||||
|
||||
// MarshalProgressToJSON converts progress data to JSON
|
||||
func MarshalProgressToJSON(progress *ProgressData) ([]byte, error) {
|
||||
return json.Marshal(progress)
|
||||
}
|
||||
|
||||
const CharsPerPage int64 = 1800
|
||||
|
||||
func EstimatedPages(totalCharacters int64) int {
|
||||
|
||||
Reference in new issue
Block a user