Skip to content

Commit

Permalink
Show wiki page versions working within tabbed view on plugin pages.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.codehaus.org/grails/trunk@8651 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
  • Loading branch information
rhyolight committed Feb 20, 2009
1 parent aeea49d commit 677c0a8
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 107 deletions.
40 changes: 20 additions & 20 deletions .classpath
Expand Up @@ -80,16 +80,16 @@
<classpathentry kind="var" path="GRAILS_HOME/lib/start.jar" />
<classpathentry kind="var" path="GRAILS_HOME/lib/svnkit-1.2.0.jar" />
<classpathentry kind="var" path="GRAILS_HOME/lib/xpp3_min-1.1.3.4.O.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-bootstrap-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-core-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-crud-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-gorm-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-resources-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-scripts-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-spring-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-test-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-web-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-webflow-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-bootstrap-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-core-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-crud-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-gorm-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-resources-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-scripts-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-spring-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-test-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-web-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-webflow-1.1-SNAPSHOT.jar" />
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
Expand Down Expand Up @@ -173,14 +173,14 @@
<classpathentry kind="var" path="GRAILS_HOME/lib/start.jar" />
<classpathentry kind="var" path="GRAILS_HOME/lib/svnkit-1.2.0.jar" />
<classpathentry kind="var" path="GRAILS_HOME/lib/xpp3_min-1.1.3.4.O.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-bootstrap-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-core-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-crud-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-gorm-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-resources-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-scripts-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-spring-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-test-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-web-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-webflow-1.1-RC1.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-bootstrap-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-core-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-crud-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-gorm-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-resources-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-scripts-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-spring-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-test-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-web-1.1-SNAPSHOT.jar" />
<classpathentry kind="var" path="GRAILS_HOME/dist/grails-webflow-1.1-SNAPSHOT.jar" />
</classpath>
6 changes: 3 additions & 3 deletions application.properties
@@ -1,5 +1,5 @@
#utf-8
#Thu Feb 19 07:49:57 CST 2009
#Fri Feb 20 08:27:33 CST 2009
plugins.mail=0.5
plugins.jsecurity=0.3
app.version=2.6
Expand All @@ -8,8 +8,8 @@ plugins.quartz=0.4.1-SNAPSHOT
plugins.grails-ui=1.1-SNAPSHOT
app.servlet.version=2.4
plugins.bubbling=1.5.1
plugins.hibernate=1.1-RC1
plugins.hibernate=1.1-SNAPSHOT
app.name=site
app.grails.version=1.1-RC1
app.grails.version=1.1-SNAPSHOT
plugins.feeds=1.4
plugins.yui=2.6.1
4 changes: 2 additions & 2 deletions build.xml
Expand Up @@ -43,9 +43,9 @@

<macrodef name="grails">
<attribute name="script"/>
<attribute name="args" default="" />
<attribute name="args" default="" />
<sequential>
<grailsTask script="@{script}" args="--non-interactive @{args}" classpathref="grails.classpath">
<grailsTask script="@{script}" args="@{args}" classpathref="grails.classpath">
<compileClasspath refid="compile.classpath"/>
<testClasspath refid="test.classpath"/>
<runtimeClasspath refid="app.classpath"/>
Expand Down
Expand Up @@ -22,6 +22,7 @@ class JSecurityAuthFilters {
d.render(template:"/user/loginForm", model:[originalURI:d.request.forwardURI,
formData:d.params,
async:true,
update:d.params.update
message:"auth.not.logged.in"])
} else {
// Redirect to login page.
Expand Down
25 changes: 21 additions & 4 deletions grails-app/controllers/org/grails/ContentController.groovy
Expand Up @@ -10,8 +10,9 @@ import org.grails.content.notifications.ContentAlertStack
import org.grails.wiki.BaseWikiController
import org.grails.comment.Comment
import org.grails.content.Content
import org.grails.plugin.Plugin

class ContentController extends BaseWikiController{
class ContentController extends BaseWikiController {

static accessControl = {
// Alternatively, several actions can be specified.
Expand Down Expand Up @@ -90,7 +91,23 @@ class ContentController extends BaseWikiController{
if(pageName) {
if(pageName == 'Home') {
render(view:"homePage")
} else {
}
// treat plugin pages differently
else if (pageName.matches(/(${Plugin.WIKIS.join('|')})-[0-9]*/)) {
println "trying to show a plugin wiki: ${pageName}"
// name will look like this: description-34
// last half is plugin id
def plugin = Plugin.get(pageName.split('-')[1])
println "plugin: $plugin.name"
if (request.xhr) {
println 'ajax request'
// update the wikiTab, not the whole contentPane
def wikiPage = getCachedOrReal(pageName)
return render(template:"wikiShow", model:[content:wikiPage, update:"${pageName.split('-')[0]}Tab"])
}
redirect(controller:'plugin', action:'show', params:[name:plugin.name])
}
else {
def wikiPage = getCachedOrReal(pageName)
if(wikiPage) {
if(request.xhr) {
Expand Down Expand Up @@ -142,7 +159,7 @@ class ContentController extends BaseWikiController{
}

if(version) {
render(view:"showVersion", model:[content:version])
render(view:"showVersion", model:[content:version, update:params.update])
}
else {
render(view:"contentPage", model:[content:page])
Expand All @@ -166,7 +183,7 @@ class ContentController extends BaseWikiController{
def pageVersions = Version.findAllByCurrent(page)
pageVersions = pageVersions.sort { it.number }

render(template:'wikiInfo',model:[wikiPage:page, versions:pageVersions])
render(template:'wikiInfo',model:[wikiPage:page, versions:pageVersions, update:params.update])
}

}
Expand Down
18 changes: 9 additions & 9 deletions grails-app/controllers/org/grails/plugin/PluginController.groovy
Expand Up @@ -2,11 +2,11 @@

package org.grails.plugin

import org.grails.wiki.BaseWikiController
import org.grails.wiki.WikiPage
import org.grails.comment.Comment
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import org.grails.auth.User
import org.grails.wiki.BaseWikiController

class PluginController extends BaseWikiController {

Expand All @@ -24,7 +24,7 @@ class PluginController extends BaseWikiController {
}.sort { it.title }
}
pluginMap = pluginMap.sort { it.key }
pluginMap.untagged = Plugin.withCriteria { isEmpty('tags') }
pluginMap.untagged = Plugin.withCriteria { isEmpty('tags') }.sort { it.title }
render view:'listPlugins', model:[pluginMap: pluginMap]
}

Expand Down Expand Up @@ -118,14 +118,14 @@ class PluginController extends BaseWikiController {

def addTag = {
def plugin = Plugin.get(params.id)

def tag = Tag.findByName(params.newTag)
if (!tag) {
tag = new Tag(name: params.newTag)
tag.save()
params.newTag.trim().split(',').each { newTag ->
def tag = Tag.findByName(newTag)
if (!tag) {
tag = new Tag(name: newTag)
tag.save()
}
plugin.addToTags(tag)
}

plugin.addToTags(tag)
assert plugin.save()
render(template:'tags', var:'plugin', bean:plugin)
}
Expand Down
2 changes: 1 addition & 1 deletion grails-app/jobs/MasterPluginTranslationJob.groovy
Expand Up @@ -2,7 +2,7 @@
class MasterPluginTranslationJob {
def pluginService

def startDelay = 120000 // 120 second start-up
def startDelay = 30000 // 120 second start-up
def timeout = 3600000 // execute job every hour

def execute() {
Expand Down
30 changes: 29 additions & 1 deletion grails-app/services/org/grails/plugin/PluginService.groovy
Expand Up @@ -33,7 +33,7 @@ class PluginService {
p.with {
name = pxml.@name
title = latestRelease.title.toString() ?: pxml.@name
description = new WikiPage(title:'Description', body:latestRelease.description.toString() ?: 'Not provided')
description = new WikiPage(body:latestRelease.description.toString() ?: 'Not provided')
author = latestRelease.author
authorEmail = latestRelease.authorEmail
documentationUrl = latestRelease.documentation
Expand Down Expand Up @@ -62,10 +62,30 @@ class PluginService {
}

if (!plugin) {
// injecting a unique wiki page name for description
// pull off the desc so we don't try to save it
def descWiki = master.description
master.description = null
// so we need to save the master first to get its id
if (!master.save()) {
log.error "Could not save master plugin: $master.name ($master.title), version $master.currentRelease"
master.errors.allErrors.each { log.error "\t$it" }
}
// put the wiki page back with a unique title
descWiki.title = "description-${master.id}"
master.description = descWiki
// println "No existing plugin, creating new ==> ${master.name}"
// before saving the master, we need to save the description wiki page
if (!master.description.save() && master.description.hasErrors()) {
master.description.errors.allErrors.each { log.error it }
} else {
def v = master.description.createVersion()
v.author = User.findByLogin('admin')
try {
v.save(flush:true)
} catch (Exception e) {
println "WARNING: Can't save version ${v.title} (${v.number})"
}
}
// save new master plugin
if (!master.save()) {
Expand Down Expand Up @@ -111,6 +131,14 @@ class PluginService {
// println "Local plugin '$plugin.name' was not updated properly... errors follow:"
log.warn "Local plugin '$plugin.name' was not updated properly... errors follow:"
// plugin.errors.allErrors.each { log.warn it; println it }
} else {
def v = plugin.description.createVersion()
v.author = User.findByLogin('admin')
try {
assert v.save(flush:true)
} catch (Exception e) {
println "WARNING: Can't save version ${v.title} (${v.number})"
}
}

// println "Local plugin '$plugin.name' was updated with master version."
Expand Down
32 changes: 20 additions & 12 deletions grails-app/views/content/_editActions.gsp
@@ -1,25 +1,33 @@
<div id="editLinks" style="margin-left:230px;">

<a class="actionIcon" onclick="Effect.Appear('uploadDialog')">
<img src="${createLinkTo(dir:'images/','icon-upload.png')}" width="15" height="15" alt="Icon Image Upload" class="inlineIcon" border="0" />
<img src="${createLinkTo(dir: 'images/', 'icon-upload.png')}" width="15" height="15" alt="Icon Image Upload" class="inlineIcon" border="0"/>
</a>
<a href="#" onclick="Effect.Appear('uploadDialog')">Upload Image</a>&nbsp;&nbsp;

<a class="actionIcon" onclick="new Ajax.Updater('previewPane','${createLink(controller:'content',action:'previewWikiPage',id:content?.title)}',getAjaxOptions(function(){showPreview()}));return false">
<img src="${createLinkTo(dir:'images/','icon-preview.png')}" width="18" height="15" alt="Icon Edit" class="inlineIcon" border="0" />
<a class="actionIcon" onclick="new Ajax.Updater('previewPane', '${createLink(controller:'content',action:'previewWikiPage',id:content?.title)}', getAjaxOptions(function() {
showPreview()
}));
return false">
<img src="${createLinkTo(dir: 'images/', 'icon-preview.png')}" width="18" height="15" alt="Icon Edit" class="inlineIcon" border="0"/>
</a>
<a href="#" onclick="new Ajax.Updater('previewPane','${createLink(controller:'content',action:'previewWikiPage',id:content?.title)}',getAjaxOptions(function(){showPreview()}));return false">Preview</a>&nbsp;&nbsp;
<a href="#" onclick="new Ajax.Updater('previewPane', '${createLink(controller:'content',action:'previewWikiPage',id:content?.title)}', getAjaxOptions(function() {
showPreview()
}));
return false">Preview</a>&nbsp;&nbsp;


<a class="actionIcon" onclick="new Ajax.Updater('contentPane','${createLink(controller:'content',action:'saveWikiPage',id:content?.title)}',getAjaxOptions());return false">
<img src="${createLinkTo(dir:'images/','icon-save.png')}" width="15" height="15" alt="Icon Save" class="inlineIcon" border="0" />
</a>
<a href="#" onclick="new Ajax.Updater('contentPane','${createLink(controller:'content',action:'saveWikiPage',id:content?.title)}',getAjaxOptions());return false">Save</a>&nbsp;&nbsp;

<g:remoteLink class="actionIcon" update="contentPane" controller="content" id="${content?.title}" params="[xhr:true]"><img src="${createLinkTo(dir:'images/','icon-cancel.png')}" width="15" height="15" alt="Icon Cancel" class="inlineIcon" border="0" /></g:remoteLink>
<a class="actionIcon" onclick="new Ajax.Updater('contentPane', '${createLink(controller:'content',action:'saveWikiPage',id:content?.title)}', getAjaxOptions());
return false">
<img src="${createLinkTo(dir: 'images/', 'icon-save.png')}" width="15" height="15" alt="Icon Save" class="inlineIcon" border="0"/>
</a>
<a href="#" onclick="new Ajax.Updater('contentPane', '${createLink(controller:'content',action:'saveWikiPage',id:content?.title)}', getAjaxOptions());
return false">Save</a>&nbsp;&nbsp;

<g:remoteLink class="actionIcon" update="contentPane" controller="content" id="${content?.title}" params="[xhr:true]"><img src="${createLinkTo(dir: 'images/', 'icon-cancel.png')}" width="15" height="15" alt="Icon Cancel" class="inlineIcon" border="0"/></g:remoteLink>
<g:remoteLink update="contentPane" controller="content" id="${content?.title}" params="[xhr:true]">Cancel</g:remoteLink>
<g:remoteLink class="actionIcon" action="infoWikiPage" id="${content?.title}" update="contentPane">
<img border="0" src="${createLinkTo(dir:'images/','icon-info.png')}" width="15" height="15" alt="Icon Edit" class="inlineIcon" border="0" />
<img border="0" src="${createLinkTo(dir: 'images/', 'icon-info.png')}" width="15" height="15" alt="Icon Edit" class="inlineIcon" border="0"/>
</g:remoteLink>
<g:remoteLink action="infoWikiPage" id="${content?.title}" update="contentPane"> View Info</g:remoteLink>
<g:remoteLink action="infoWikiPage" id="${content?.title}" update="contentPane">View Info</g:remoteLink>
</div>
5 changes: 3 additions & 2 deletions grails-app/views/content/_versionList.gsp
@@ -1,14 +1,15 @@
<g:set var="updateElement" value="${update ?: 'contentPane'}" />
<g:if test="${message}">
<div id="message" class="message">${message}</div>
</g:if>
<ul>

<g:each in="${versions}" var="v">
<li>
<g:remoteLink update="contentPane"
<g:remoteLink update="${updateElement}"
controller="content"
action="showWikiVersion" id="${wikiPage?.title}"
params="[number:v.number]">
params="[number:v.number, update:updateElement]">
Version ${v.number}</g:remoteLink> (Updated by <strong>${v.author.login}</strong>)

<jsec:authenticated>
Expand Down
12 changes: 7 additions & 5 deletions grails-app/views/content/_viewActions.gsp
@@ -1,18 +1,20 @@
<div id="viewLinks" style="margin-left:500px;">

<g:set var="updateElement" value="${update ?: 'contentPane'}"/>

<g:if test="${content?.locked}">
LOCKED<br/>
</g:if>
<g:else>
<g:remoteLink class="actionIcon" action="editWikiPage" id="${content?.title}" update="contentPane">
<g:remoteLink class="actionIcon" controller="content" action="editWikiPage" id="${content?.title}" update="${updateElement}">
<img border="0" src="${createLinkTo(dir:'images/','icon-edit.png')}" width="15" height="15" alt="Icon Edit" class="inlineIcon" border="0" />
</g:remoteLink>
<g:remoteLink action="editWikiPage" id="${content?.title}" update="contentPane">Edit</g:remoteLink>
<g:remoteLink class="actionIcon" controller="content" action="editWikiPage" id="${content?.title}" update="${updateElement}">Edit</g:remoteLink>
</g:else>

<g:remoteLink class="actionIcon" action="infoWikiPage" id="${content?.title}" update="contentPane">
<br/>
<g:remoteLink class="actionIcon" controller="content" action="infoWikiPage" id="${content?.title}" params="[update:updateElement]" update="${updateElement}">
<img border="0" src="${createLinkTo(dir:'images/','icon-info.png')}" width="15" height="15" alt="Icon Edit" class="inlineIcon" border="0" />
</g:remoteLink>
<g:remoteLink action="infoWikiPage" id="${content?.title}" update="contentPane">View Info</g:remoteLink>
<g:remoteLink controller="content" action="infoWikiPage" id="${content?.title}" params="[update:updateElement]" update="${updateElement}">View Info</g:remoteLink>

</div>

0 comments on commit 677c0a8

Please sign in to comment.