Unify PDF pagination system and rename templates
This commit is contained in:
@@ -20,12 +20,12 @@ func GenerateContinuationTemplateName(originalTemplate string, pageNum int) stri
|
||||
// Pattern: page_N.html where N is a number
|
||||
ext := ".html"
|
||||
base := strings.TrimSuffix(originalTemplate, ext)
|
||||
|
||||
|
||||
// Check if it's already a continuation (has .2 in it)
|
||||
if strings.Contains(base, ".2") {
|
||||
return originalTemplate
|
||||
}
|
||||
|
||||
|
||||
// Append .2 before .html
|
||||
return fmt.Sprintf("%s.2%s", base, ext)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func ExtractBaseTemplateName(templateName string) string {
|
||||
|
||||
// Remove .html
|
||||
base := strings.TrimSuffix(templateName, ext)
|
||||
|
||||
|
||||
// Find the last dot
|
||||
lastDotIdx := strings.LastIndex(base, ".")
|
||||
if lastDotIdx == -1 {
|
||||
|
||||
@@ -166,9 +166,9 @@ func TestPaginateMultiList_WithOverflow(t *testing.T) {
|
||||
for _, dist := range distributions {
|
||||
for blockName, data := range dist.Data {
|
||||
// Only count skill blocks to avoid counting the same skills multiple times
|
||||
if skillsList, ok := data.([]SkillViewModel); ok &&
|
||||
(blockName == "skills_column1" || blockName == "skills_column2" ||
|
||||
blockName == "skills_column3" || blockName == "skills_column4") {
|
||||
if skillsList, ok := data.([]SkillViewModel); ok &&
|
||||
(blockName == "skills_column1" || blockName == "skills_column2" ||
|
||||
blockName == "skills_column3" || blockName == "skills_column4") {
|
||||
totalSkills += len(skillsList)
|
||||
}
|
||||
}
|
||||
@@ -837,7 +837,7 @@ func TestCalculatePagesNeeded(t *testing.T) {
|
||||
{"10 skills on page1", "page_1.html", "skills", 10, 1},
|
||||
{fmt.Sprintf("%d skills on page1", skillCapacity), "page_1.html", "skills", skillCapacity, 1},
|
||||
{fmt.Sprintf("%d skills on page1", skillCapacity+1), "page_1.html", "skills", skillCapacity + 1, 2},
|
||||
{"100 skills on page1", "page_1.html", "skills", 100, (100 + skillCapacity - 1) / skillCapacity}, // Dynamic calculation
|
||||
{"100 skills on page1", "page_1.html", "skills", 100, (100 + skillCapacity - 1) / skillCapacity}, // Dynamic calculation
|
||||
{"10 weapons on page2", "page_2.html", "weapons", 10, (10 + weaponCapacity - 1) / weaponCapacity}, // Dynamic calculation
|
||||
{fmt.Sprintf("%d weapons on page2", weaponCapacity), "page_2.html", "weapons", weaponCapacity, 1},
|
||||
{fmt.Sprintf("%d weapons on page2", weaponCapacity+1), "page_2.html", "weapons", weaponCapacity + 1, 2},
|
||||
|
||||
Reference in New Issue
Block a user