Display MPA in default theme (as index item).
parent
496d0ac462
commit
591bb6b1d2
|
|
@ -5,6 +5,7 @@
|
||||||
"build": "npm-run-all build:*",
|
"build": "npm-run-all build:*",
|
||||||
"build:mkdir": "shx mkdir -p target/generated-resources/themes/librecms",
|
"build:mkdir": "shx mkdir -p target/generated-resources/themes/librecms",
|
||||||
"build:theme": "shx cp -r src/main/resources/themes/librecms/* target/generated-resources/themes/librecms",
|
"build:theme": "shx cp -r src/main/resources/themes/librecms/* target/generated-resources/themes/librecms",
|
||||||
|
"build:icons": "shx cp node_modules/bootstrap-icons/bootstrap-icons.svg target/generated-resources/themes/librecms/images/",
|
||||||
"build:js": "webpack",
|
"build:js": "webpack",
|
||||||
"build:css": "npm-run-all build:css:*",
|
"build:css": "npm-run-all build:css:*",
|
||||||
"build:css:librecms": "sass src/main/scss/librecms.scss target/generated-resources/themes/librecms/styles/librecms.css",
|
"build:css:librecms": "sass src/main/scss/librecms.scss target/generated-resources/themes/librecms/styles/librecms.css",
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,54 @@
|
||||||
<ul class="flex-column float-end nav">
|
<ul class="flex-column float-end nav">
|
||||||
<#list CmsPagesMultiPartArticleModel.sectionTitles as section>
|
<#list CmsPagesMultiPartArticleModel.sectionTitles as section>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link"
|
<#if section?index == CmsPagesMultiPartArticleModel.currentSection>
|
||||||
href="${CmsPagesMultiPartArticleModel.sectionLinks[section?index]}">
|
<a aria-current="page"
|
||||||
${section}
|
class="active nav-link"
|
||||||
</a>
|
href="${CmsPagesMultiPartArticleModel.sectionLinks[section?index]}">
|
||||||
|
${section}
|
||||||
|
</a>
|
||||||
|
<#else>
|
||||||
|
<a class="nav-link"
|
||||||
|
href="${CmsPagesMultiPartArticleModel.sectionLinks[section?index]}">
|
||||||
|
${section}
|
||||||
|
</a>
|
||||||
|
</#if>
|
||||||
</li>
|
</li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
${CmsPagesMultiPartArticleModel.currentSectionText}
|
${CmsPagesMultiPartArticleModel.currentSectionText}
|
||||||
|
<nav>
|
||||||
|
<ul class="pagination">
|
||||||
|
<#if CmsPagesMultiPartArticleModel.prevSectionLink != "">
|
||||||
|
<li class="list-item">
|
||||||
|
<a class="page-link"
|
||||||
|
href="${CmsPagesMultiPartArticleModel.prevSectionLink}">
|
||||||
|
<svg class="bi"
|
||||||
|
fill="current-color"
|
||||||
|
height="1em"
|
||||||
|
width="1em">
|
||||||
|
<use xlink:href="${themeUrl}/images/bootstrap-icons.svg#caret-left-fill" />
|
||||||
|
</svg>
|
||||||
|
<span class="visually-hidden">Previous</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</#if>
|
||||||
|
<#if CmsPagesMultiPartArticleModel.nextSectionLink != "">
|
||||||
|
<li class="list-item">
|
||||||
|
<a class="page-link"
|
||||||
|
href="${CmsPagesMultiPartArticleModel.nextSectionLink}">
|
||||||
|
<svg class="bi"
|
||||||
|
fill="current-color"
|
||||||
|
height="1em"
|
||||||
|
width="1em">
|
||||||
|
<use xlink:href="${themeUrl}/images/bootstrap-icons.svg#caret-right-fill" />
|
||||||
|
</svg>
|
||||||
|
<span class="visually-hidden">Next</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</#if>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.pages.models;
|
package org.librecms.pages.models;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
@ -35,9 +36,6 @@ import org.librecms.contentsection.ContentItem;
|
||||||
import org.librecms.contenttypes.MultiPartArticle;
|
import org.librecms.contenttypes.MultiPartArticle;
|
||||||
import org.librecms.contenttypes.MultiPartArticleSection;
|
import org.librecms.contenttypes.MultiPartArticleSection;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
@ -67,6 +65,12 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
|
|
||||||
private List<String> sectionLinks;
|
private List<String> sectionLinks;
|
||||||
|
|
||||||
|
private String prevSectionLink;
|
||||||
|
|
||||||
|
private String nextSectionLink;
|
||||||
|
|
||||||
|
private int currentSection;
|
||||||
|
|
||||||
private String currentSectionTitle;
|
private String currentSectionTitle;
|
||||||
|
|
||||||
private String currentSectionText;
|
private String currentSectionText;
|
||||||
|
|
@ -105,6 +109,27 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
return Collections.unmodifiableList(sectionLinks);
|
return Collections.unmodifiableList(sectionLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String getPrevSectionLink() {
|
||||||
|
contentItemModel.init();
|
||||||
|
|
||||||
|
return prevSectionLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String getNextSectionLink() {
|
||||||
|
contentItemModel.init();
|
||||||
|
|
||||||
|
return nextSectionLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public int getCurrentSection() {
|
||||||
|
contentItemModel.init();
|
||||||
|
|
||||||
|
return currentSection;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String getCurrentSectionTitle() {
|
public String getCurrentSectionTitle() {
|
||||||
contentItemModel.init();
|
contentItemModel.init();
|
||||||
|
|
@ -156,9 +181,8 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
)
|
)
|
||||||
.orElse(Collections.emptyList());
|
.orElse(Collections.emptyList());
|
||||||
|
|
||||||
sectionLinks = buildSectionLinks();
|
currentSection = readCurrentSection();
|
||||||
|
|
||||||
final int currentSection = readCurrentSection();
|
|
||||||
if (mpa.getSections().size() < currentSection) {
|
if (mpa.getSections().size() < currentSection) {
|
||||||
throw new WebApplicationException(
|
throw new WebApplicationException(
|
||||||
Response
|
Response
|
||||||
|
|
@ -189,6 +213,7 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
.orElse("");
|
.orElse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sectionLinks = buildSectionLinks();
|
||||||
sections = mpa
|
sections = mpa
|
||||||
.getSections()
|
.getSections()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
@ -236,8 +261,26 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
final int size = sectionTitles.size();
|
final int size = sectionTitles.size();
|
||||||
final List<String> sectionLinksList = new ArrayList<>();
|
final List<String> sectionLinksList = new ArrayList<>();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
sectionLinksList.add(
|
sectionLinksList.add(buildSectionLink(i));
|
||||||
String.format(
|
}
|
||||||
|
|
||||||
|
if (currentSection == 0) {
|
||||||
|
prevSectionLink = "";
|
||||||
|
} else {
|
||||||
|
prevSectionLink = buildSectionLink(currentSection - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSection < sectionLinksList.size() - 1) {
|
||||||
|
nextSectionLink = buildSectionLink(currentSection + 1);
|
||||||
|
} else {
|
||||||
|
nextSectionLink = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return sectionLinksList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildSectionLink(final int section) {
|
||||||
|
return String.format(
|
||||||
"?%s&%s=%d",
|
"?%s&%s=%d",
|
||||||
pageUrlModel
|
pageUrlModel
|
||||||
.getQueryParameters()
|
.getQueryParameters()
|
||||||
|
|
@ -257,12 +300,8 @@ public class MultiPartArticleModel implements ProcessesContentItem {
|
||||||
)
|
)
|
||||||
.collect(Collectors.joining("&")),
|
.collect(Collectors.joining("&")),
|
||||||
MPA_SECTION_QUERY_PARAM,
|
MPA_SECTION_QUERY_PARAM,
|
||||||
i
|
section
|
||||||
)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sectionLinksList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue