Basic composition page working.
This commit is contained in:
parent
ddf26d199e
commit
0bcbc66118
@ -1,6 +1,5 @@
|
|||||||
package com.jessebrault.site.composition
|
package com.jessebrault.site.composition
|
||||||
|
|
||||||
|
|
||||||
import groowt.view.component.web.BaseWebViewComponent
|
import groowt.view.component.web.BaseWebViewComponent
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.jessebrault.site.composition
|
||||||
|
|
||||||
|
import com.jessebrault.site.util.TitleMaker
|
||||||
|
import com.jessebrault.ssg.view.WvcPageView
|
||||||
|
import jakarta.inject.Inject
|
||||||
|
|
||||||
|
class CompositionPage extends WvcPageView {
|
||||||
|
|
||||||
|
Composition composition
|
||||||
|
private final TitleMaker titleMaker
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CompositionPage(TitleMaker titleMaker) {
|
||||||
|
this.titleMaker = titleMaker
|
||||||
|
}
|
||||||
|
|
||||||
|
String getTitle() {
|
||||||
|
this.titleMaker.makeTitle(pageTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.jessebrault.site.composition
|
||||||
|
|
||||||
|
import com.jessebrault.site.CompositionsPage
|
||||||
|
import com.jessebrault.ssg.page.Page
|
||||||
|
import com.jessebrault.ssg.page.PageFactory
|
||||||
|
import com.jessebrault.ssg.view.WvcCompiler
|
||||||
|
import groowt.util.di.RegistryObjectFactory
|
||||||
|
import jakarta.inject.Inject
|
||||||
|
|
||||||
|
class CompositionPageFactory implements PageFactory {
|
||||||
|
|
||||||
|
private final RegistryObjectFactory objectFactory
|
||||||
|
private final CompositionContainer compositions
|
||||||
|
private final WvcCompiler wvcCompiler
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CompositionPageFactory(
|
||||||
|
RegistryObjectFactory objectFactory,
|
||||||
|
CompositionContainer compositions,
|
||||||
|
WvcCompiler wvcCompiler
|
||||||
|
) {
|
||||||
|
this.objectFactory = objectFactory
|
||||||
|
this.compositions = compositions
|
||||||
|
this.wvcCompiler = wvcCompiler
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Collection<Page> create() {
|
||||||
|
this.compositions.all.collect { composition ->
|
||||||
|
new CompositionPageType(
|
||||||
|
name: composition.title,
|
||||||
|
path: "/compositions/$composition.slug",
|
||||||
|
fileExtension: '.html',
|
||||||
|
viewType: CompositionPage,
|
||||||
|
objectFactory: objectFactory,
|
||||||
|
wvcCompiler: wvcCompiler,
|
||||||
|
composition: composition
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.jessebrault.site.composition
|
||||||
|
|
||||||
|
import com.jessebrault.ssg.page.DefaultWvcPage
|
||||||
|
import com.jessebrault.ssg.util.Diagnostic
|
||||||
|
import com.jessebrault.ssg.view.PageView
|
||||||
|
import groowt.util.fp.either.Either
|
||||||
|
|
||||||
|
class CompositionPageType extends DefaultWvcPage {
|
||||||
|
|
||||||
|
final Composition composition
|
||||||
|
|
||||||
|
CompositionPageType(Map args) {
|
||||||
|
super(args)
|
||||||
|
composition = args.composition
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Either<Diagnostic, PageView> createView() {
|
||||||
|
def result = super.createView()
|
||||||
|
if (result.isRight()) {
|
||||||
|
def compositionPage = result.getRight() as CompositionPage
|
||||||
|
compositionPage.composition = this.composition
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int hashCode() {
|
||||||
|
31 * super.hashCode() + composition.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean equals(Object obj) {
|
||||||
|
if (!super.equals(obj)) {
|
||||||
|
return false
|
||||||
|
} else if (obj instanceof CompositionPageType) {
|
||||||
|
return composition == obj.composition
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString() {
|
||||||
|
"CompositionPageType($composition)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
package com.jessebrault.site.composition
|
||||||
|
|
||||||
|
import com.jessebrault.site.StandardPage
|
||||||
|
---
|
||||||
|
<StandardPage title={title}>
|
||||||
|
<article>
|
||||||
|
<h1>$composition.title</h1>
|
||||||
|
</article>
|
||||||
|
</StandardPage>
|
@ -12,6 +12,7 @@ import java.time.LocalDate
|
|||||||
class Composition {
|
class Composition {
|
||||||
Text text
|
Text text
|
||||||
String title
|
String title
|
||||||
|
String slug
|
||||||
@Nullable String subTitle
|
@Nullable String subTitle
|
||||||
@Nullable String version
|
@Nullable String version
|
||||||
String instrumentation
|
String instrumentation
|
||||||
|
@ -16,6 +16,7 @@ class CompositionContainer {
|
|||||||
new Composition(
|
new Composition(
|
||||||
text: text,
|
text: text,
|
||||||
title: text.frontMatter.title,
|
title: text.frontMatter.title,
|
||||||
|
slug: text.frontMatter.slug,
|
||||||
subTitle: text.frontMatter.subTitle,
|
subTitle: text.frontMatter.subTitle,
|
||||||
version: text.frontMatter.version,
|
version: text.frontMatter.version,
|
||||||
instrumentation: text.frontMatter.instrumentation,
|
instrumentation: text.frontMatter.instrumentation,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: Spirit Travels
|
title: Spirit Travels
|
||||||
|
slug: spirit-travels
|
||||||
version: Chamber orchestra version
|
version: Chamber orchestra version
|
||||||
instrumentation: For fl, ob, cl, hn, 2 perc, pno, and strings 2.2.2.2.1.
|
instrumentation: For fl, ob, cl, hn, 2 perc, pno, and strings 2.2.2.2.1.
|
||||||
shortInfo: <em>In memoriam</em> Jane H. Kim.
|
shortInfo: <em>In memoriam</em> Jane H. Kim.
|
||||||
|
Loading…
Reference in New Issue
Block a user