From: Sven Arnold Date: Mon, 13 Apr 2009 12:03:51 +0000 (+0200) Subject: added news X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=cd9da64d684ebe687acdffec2dbe6e49884ebd7b;p=Grails-CMS.git added news --- diff --git a/Portal.iws b/Portal.iws index e603a54..5e56ca2 100644 --- a/Portal.iws +++ b/Portal.iws @@ -4,15 +4,12 @@ + - - - - - + @@ -71,46 +68,55 @@ + + + + + + + + + - + - - + + - + - - + + - + - - + + - + - - + + - + @@ -122,25 +128,28 @@ - + - - + + - + - - + + + + + - + @@ -154,8 +163,8 @@ - + @@ -587,7 +408,7 @@ - + @@ -599,11 +420,11 @@ - + - - + + @@ -621,7 +442,7 @@ @@ -649,123 +471,126 @@ - + - + + + + - + - + - + - + - - - - + - + - + - + + + + - + - + - - - - + - + - + - + - + - - - - + - + - + - + - + - + - + - + + + + - + - + + + + - + - + - + - + diff --git a/grails-app/conf/BootStrap.groovy b/grails-app/conf/BootStrap.groovy index fb2ba25..972eeef 100644 --- a/grails-app/conf/BootStrap.groovy +++ b/grails-app/conf/BootStrap.groovy @@ -1,36 +1,43 @@ class BootStrap { - def init = { servletContext -> + def init = {servletContext -> - // initialize configuration - def config = new PortalConfiguration(name: "default", title: "Schnuppe Portal", motto: "A new star is born", theme: "grey") - assert config.save() + switch (GrailsUtil.environment) { + case "development": + break + // initialize configuration + def config = new PortalConfiguration(name: "default", title: "Schnuppe Portal", motto: "A new star is born", theme: "grey") + assert config.save() - // some top level pages - def root1 = new Page(title: "Home", author: "sven", language: "en", content: "My Home is my castle.") - def root2 = new Page(title: "About Me", author: "sven", language: "en", content: "I am drunk and sick.") - def root3 = new Page(title: "Word of the Day", author: "sven", language: "en", content: "Miksch's Law:
If a string has one end, then it has another end.") - assert root1.save() - assert root2.save() - assert root3.save() + // some top level pages + def root1 = new Page(title: "Home", author: "sven", language: "en", content: "My Home is my castle.") + def root2 = new Page(title: "About Me", author: "sven", language: "en", content: "I am drunk and sick.") + def root3 = new Page(title: "Word of the Day", author: "sven", language: "en", content: "Miksch's Law:
If a string has one end, then it has another end.") + assert root1.save() + assert root2.save() + assert root3.save() - // some second level pages - def child3 = new Page(title:"No Info", author: "sven", language: "en", content: "Nothing", ordinal: 3, parent: root1) - def child2 = new Page(title:"Less Info", author: "sven", language: "en", content: "Not much", ordinal: 2, parent: root1) - def child1 = new Page(title:"Info", author: "sven", language: "en", content: "Too much", ordinal: 1, parent: root1) - assert child1.save() - assert child2.save() - assert child3.save() + // some second level pages + def child3 = new Page(title: "No Info", author: "sven", language: "en", content: "Nothing", ordinal: 3, parent: root1) + def child2 = new Page(title: "Less Info", author: "sven", language: "en", content: "Not much", ordinal: 2, parent: root1) + def child1 = new Page(title: "Info", author: "sven", language: "en", content: "Too much", ordinal: 1, parent: root1) + assert child1.save() + assert child2.save() + assert child3.save() - // a controller page with some news -// def news1 = new News(content: "Portal Applicaton created.") -// def news2 = new News(content: "Portal Application instantiated.") -// assert news1.save() -// assert news2.save() -// def newsPage = new Page(title: "News", author: "Sven", language: "de", content: "", controller: "news", parent: root2) -// assert newsPage.save() - } + // a controller page with some news + def news1 = new News(title: "Creation", content: "Portal Applicaton created.") + def news2 = new News(title: "Startup", content: "Portal Application instantiated.") + assert news1.save() + assert news2.save() + def newsPage = new Page(title: "News", author: "sven", language: "en", content: "", controllerName: "news", parent: root2) + assert newsPage.save() - def destroy = { - } + case "production": + break + } + } + + def destroy = { + } } \ No newline at end of file diff --git a/grails-app/controllers/NewsController.groovy b/grails-app/controllers/NewsController.groovy index f93521f..f9474c7 100644 --- a/grails-app/controllers/NewsController.groovy +++ b/grails-app/controllers/NewsController.groovy @@ -97,5 +97,8 @@ class NewsController { } } - + def display = { + params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) + [ newsInstanceList: News.list( params ), newsInstanceTotal: News.count() ] + } } diff --git a/grails-app/controllers/PageController.groovy b/grails-app/controllers/PageController.groovy index f3127cf..3143946 100644 --- a/grails-app/controllers/PageController.groovy +++ b/grails-app/controllers/PageController.groovy @@ -109,9 +109,12 @@ class PageController { // if (pageInstance instanceof ControllerPage) { // redirect(controller: pageInstance.controller, action: 'list') // } - - return [pageInstance: pageInstance, subNavigation: pageInstance.getNavigationPages() ] + + if (pageInstance.hasControllerName()) { + chain(controller: pageInstance.controllerName, action: 'display', model: [pageInstance: pageInstance, subNavigation: pageInstance.getNavigationPages() ]) + } else { + return [pageInstance: pageInstance, subNavigation: pageInstance.getNavigationPages() ] + } } } - } diff --git a/grails-app/domain/Page.groovy b/grails-app/domain/Page.groovy index c52f254..d4eea64 100644 --- a/grails-app/domain/Page.groovy +++ b/grails-app/domain/Page.groovy @@ -13,7 +13,7 @@ class Page implements Comparable { String content // ControllerPage members - //String controller + String controllerName static constraints = { title(nullable: false, unique:true) @@ -22,7 +22,7 @@ class Page implements Comparable { author(nullable: false) language(nullable:true) content(nullable:true) -// controller(nullable:true) + controllerName(nullable:true) } int compareTo(obj) { @@ -63,7 +63,7 @@ class Page implements Comparable { return parent.isAncestor(page) } -// boolean isController() { -// (controller && !controller.isEmpty()) -// } + boolean hasControllerName() { + (controllerName && !controllerName.isEmpty()) + } } diff --git a/grails-app/views/layouts/grey.gsp b/grails-app/views/layouts/grey.gsp index fb4a507..adb1641 100644 --- a/grails-app/views/layouts/grey.gsp +++ b/grails-app/views/layouts/grey.gsp @@ -15,7 +15,7 @@ diff --git a/grails-app/views/news/display.gsp b/grails-app/views/news/display.gsp new file mode 100644 index 0000000..c5e7707 --- /dev/null +++ b/grails-app/views/news/display.gsp @@ -0,0 +1,49 @@ +<%@ page contentType="text/html;charset=UTF-8" %> + + + + ${pageInstance?.title} + + + + + +

News List

+ +
${flash.message}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
${fieldValue(bean:newsInstance, field:'id')}${fieldValue(bean:newsInstance, field:'content')}${fieldValue(bean:newsInstance, field:'dateCreated')}
+
+
+ +
+ + + + diff --git a/web-app/css/grey/screen.css b/web-app/css/grey/screen.css index 0a83f54..83adaf6 100644 --- a/web-app/css/grey/screen.css +++ b/web-app/css/grey/screen.css @@ -9,7 +9,7 @@ blockquote, q {quotes:"" "";} a img {border:none;} /* typography.css */ -body {font-size:75%;color:#fff;background:#ffffff;font-family:"Verdana", "Helvetica Neue", Helvetica, sans-serif;} +body {font-size:75%;color:#000000;background:#ffffff;font-family:"Verdana", "Helvetica Neue", Helvetica, sans-serif;} h1, h2, h3, h4, h5, h6 {font-weight:normal; color:#fff;} h1 {font-size:2.5em;margin-bottom:0.5em;} h2 {font-size:2em;margin-bottom:0.75em;}