Components and di properly working.
This commit is contained in:
		
							parent
							
								
									95caca0f0c
								
							
						
					
					
						commit
						5fe7fc923e
					
				| @ -12,7 +12,5 @@ repositories { | |||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     implementation 'org.apache.groovy:groovy:4.0.21' |     implementation 'org.apache.groovy:groovy:4.0.21' | ||||||
|     ssgImplementation sourceSets.main.runtimeClasspath // TODO: put this in plugin |  | ||||||
|     pagesImplementation sourceSets.main.runtimeClasspath |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								components/groovy/com/jessebrault/site/Head.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								components/groovy/com/jessebrault/site/Head.groovy
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | |||||||
|  | package com.jessebrault.site | ||||||
|  | 
 | ||||||
|  | import groowt.view.component.web.BaseWebViewComponent | ||||||
|  | 
 | ||||||
|  | class Head extends BaseWebViewComponent { | ||||||
|  | 
 | ||||||
|  |     final String title | ||||||
|  | 
 | ||||||
|  |     Head(Map attr) { | ||||||
|  |         title = attr.title | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
							
								
								
									
										17
									
								
								components/groovy/com/jessebrault/site/StandardPage.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								components/groovy/com/jessebrault/site/StandardPage.groovy
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | package com.jessebrault.site | ||||||
|  | 
 | ||||||
|  | import groowt.view.component.web.BaseWebViewComponent | ||||||
|  | 
 | ||||||
|  | class StandardPage extends BaseWebViewComponent { | ||||||
|  | 
 | ||||||
|  |     final String title | ||||||
|  | 
 | ||||||
|  |     StandardPage(Map attr) { | ||||||
|  |         this.title = attr.title | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     List getPageChildren() { | ||||||
|  |         this.children | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | --- | ||||||
|  | package com.jessebrault.site | ||||||
|  | --- | ||||||
|  | <head> | ||||||
|  |     <meta charset="UTF-8" /> | ||||||
|  |     <title>$title</title> | ||||||
|  | </head> | ||||||
| @ -0,0 +1,9 @@ | |||||||
|  | --- | ||||||
|  | package com.jessebrault.site | ||||||
|  | --- | ||||||
|  | <html lang="en"> | ||||||
|  |     <Head title={title} /> | ||||||
|  |     <body> | ||||||
|  |         <% bodyChildren -> pageChildren.each { bodyChildren << it } %> | ||||||
|  |     </body> | ||||||
|  | </html> | ||||||
| @ -15,7 +15,6 @@ class BiographyPage extends WvcPageView { | |||||||
| 
 | 
 | ||||||
|     @Inject |     @Inject | ||||||
|     BiographyPage(TitleMaker titleMaker, @InjectText('/Biography.md') Text biography) { |     BiographyPage(TitleMaker titleMaker, @InjectText('/Biography.md') Text biography) { | ||||||
|         super(BiographyPage.getResource('BiographyPage.wvc')) |  | ||||||
|         this.titleMaker = titleMaker |         this.titleMaker = titleMaker | ||||||
|         this.biography = biography |         this.biography = biography | ||||||
|     } |     } | ||||||
| @ -24,7 +23,7 @@ class BiographyPage extends WvcPageView { | |||||||
|         biography.render() |         biography.render() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String renderTitle() { |     String getTitle() { | ||||||
|         titleMaker.makeTitle(pageTitle) |         titleMaker.makeTitle(pageTitle) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								pages/groovy/com/jessebrault/site/CompositionsPage.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								pages/groovy/com/jessebrault/site/CompositionsPage.groovy
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | |||||||
|  | package com.jessebrault.site | ||||||
|  | 
 | ||||||
|  | import com.jessebrault.site.util.TitleMaker | ||||||
|  | import com.jessebrault.ssg.page.PageSpec | ||||||
|  | import com.jessebrault.ssg.view.WvcPageView | ||||||
|  | import jakarta.inject.Inject | ||||||
|  | 
 | ||||||
|  | @PageSpec(name = 'Compositions', path = '/compositions') | ||||||
|  | class CompositionsPage extends WvcPageView { | ||||||
|  | 
 | ||||||
|  |     private final TitleMaker titleMaker | ||||||
|  | 
 | ||||||
|  |     @Inject | ||||||
|  |     CompositionsPage(TitleMaker titleMaker) { | ||||||
|  |         this.titleMaker = titleMaker | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     String getTitle() { | ||||||
|  |         titleMaker.makeTitle(pageTitle) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -1,14 +0,0 @@ | |||||||
| --- |  | ||||||
| package com.jessebrault.site |  | ||||||
| --- |  | ||||||
| <html lang="en"> |  | ||||||
|     <head> |  | ||||||
|         <meta charset="UTF-8" /> |  | ||||||
|         <title><%= renderTitle() %></title> |  | ||||||
|     </head> |  | ||||||
|     <body> |  | ||||||
|         <article> |  | ||||||
|             <%= renderBiography() %> |  | ||||||
|         </article> |  | ||||||
|     </body> |  | ||||||
| </html> |  | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | --- | ||||||
|  | package com.jessebrault.site | ||||||
|  | --- | ||||||
|  | <StandardPage title={title}> | ||||||
|  |     <article> | ||||||
|  |         <%= renderBiography() %> | ||||||
|  |     </article> | ||||||
|  | </StandardPage> | ||||||
| @ -0,0 +1,6 @@ | |||||||
|  | --- | ||||||
|  | package com.jessebrault.site | ||||||
|  | --- | ||||||
|  | <StandardPage title={title}> | ||||||
|  |     <h1>Compositions</h1> | ||||||
|  | </StandardPage> | ||||||
| @ -1,17 +1,19 @@ | |||||||
| package com.jessebrault.site.util | package com.jessebrault.site.util | ||||||
| 
 | 
 | ||||||
| import groowt.util.fp.provider.Provider | import jakarta.inject.Inject | ||||||
|  | import jakarta.inject.Named | ||||||
| 
 | 
 | ||||||
| class TitleMaker { | class TitleMaker { | ||||||
| 
 | 
 | ||||||
|     private final Provider<String> siteTitleProvider |     private final String siteTitle | ||||||
| 
 | 
 | ||||||
|     TitleMaker(Provider<String> siteTitleProvider) { |     @Inject | ||||||
|         this.siteTitleProvider = siteTitleProvider |     TitleMaker(@Named('siteName') String siteTitle) { | ||||||
|  |         this.siteTitle = siteTitle | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String makeTitle(String pageTitle) { |     String makeTitle(String pageTitle) { | ||||||
|         this.siteTitleProvider.get() + " — " + pageTitle |         this.siteTitle + " — " + pageTitle | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
|  | import com.jessebrault.site.util.TitleMaker | ||||||
| import com.jessebrault.ssg.buildscript.BuildScriptBase | import com.jessebrault.ssg.buildscript.BuildScriptBase | ||||||
| import groovy.transform.BaseScript | import groovy.transform.BaseScript | ||||||
| import com.jessebrault.site.util.TitleMaker |  | ||||||
| 
 | 
 | ||||||
| import static groowt.util.di.BindingUtil.toSingleton | import static groowt.util.di.BindingUtil.toSelf | ||||||
| 
 | 
 | ||||||
| @BaseScript | @BaseScript | ||||||
| BuildScriptBase base | BuildScriptBase base | ||||||
| @ -12,7 +12,7 @@ build { | |||||||
|     baseUrl 'https://jessebrault.com' |     baseUrl 'https://jessebrault.com' | ||||||
|     objectFactoryBuilder.configure { |     objectFactoryBuilder.configure { | ||||||
|         configureRegistry { |         configureRegistry { | ||||||
|             bind(TitleMaker, toSingleton(new TitleMaker(siteName))) |             bind(TitleMaker, toSelf()) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 JesseBrault0709
						JesseBrault0709