- CCT Public Page
- [CCT Members Area]
import com.atlassian.confluence.pages.Page;
import com.atlassian.spring.container.ContainerManager;
def index = request.getSession(true).getServletContext().getAttribute("climb.index")
if (index == null )
def totalStars = ["","*","**","***"]
def totalGrades = ["6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","VE","V0","V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13","V14","V15"]
def totalSorts = ["grade,stars,name","name","none"]
def sortBy = "grade,stars,name"
def grades = totalGrades //["17","18"]
def stars = ["***"]
def pages = ["Far North","Northern Buttress","Rockaway and Amphitheatre","The Columns","Flange Buttress","Central Buttress","Great Tier","Step Tier","Teardrop Gully","Avalanche Couloir","University Buttress","Bulging Buttress","Broken Buttress","Lost World Area","Sphinx Rock","Ferntree","Other Crags"]
def nameStartsWith = ""
def nameContains = ""
def faContains = ""
if (request.getParameter("climb.search") != null )
if (nameContains != null && nameContains.startsWith("fa "))
out.println '''
Search Criteria
Climb Search
This page lets you search the thesarvo guides by stars, grade, area etc. The criteria below all have to be satisfied, so you probably want to widen the criteria. The default search below shows the tick list of all the 3 star climbs on Mt Wellington. Use a Ctrl-click to select multiple values for stars, grade and area.
\\\\
'''
def filtered = new ArrayList();
for (c in index.climbs)
{
if ( pages.contains(c.page) && grades.contains(c.grade==null ? "" : c.grade.trim() ) && stars.contains(c.stars) )
{
if (nameContains==null || nameContains.length()==0 || c.name.toLowerCase().contains(nameContains.toLowerCase()) )
{
def fa = c.fa ?: ""
if (faContains==null || faContains.length()==0 || fa.toLowerCase().contains(faContains.toLowerCase()) )
{
if (nameStartsWith==null || nameStartsWith.length()==0 || c.name.toLowerCase().startsWith(nameStartsWith.toLowerCase()) )
{
if (grades==null || grades.size()==0)
filtered.add c
else
for (g in grades)
if (c.grade!=null && c.grade.trim().startsWith(g) )
}
}
}
}
}
if (sortBy!=null && !sortBy.equals("none"))
{
def compare = [ compare:
] as Comparator
if (sortBy.equals(totalSorts[0]))
{
compare = [ compare:
] as Comparator
}
//out.println "sorting"
filtered.sort compare
}
out.println "h2. Results"
out.print filtered.size + " results"
if (filtered.size > 600)
else
out.println ""
out.println "|| || Stars || Name || Length || Grade || Area ||"
for (c in filtered)
def addChildren(Page page, Index index)
{
for (child in page.sortedChildren)
}
def doPage (Page page, Index index)
{
out.println "Processing " + page.title
int index1 = page.bodyAsString.indexOf("<guide")
if (index1 > -1)
{
int index2 = page.bodyAsString.indexOf("</guide>",index1+1)
String xml = page.bodyAsString.substring(index1, index2+8)
//out.println ("Page:" + page )
def x = new XmlParser().parseText(xml)
def climbs = x.climb
climbs.addAll x.problem
if (climbs.size() > 0)
index.pages.add page.title
for (climb in climbs)
}
addChildren(page, index)
}
def List toList
class Index
class Climb
{
String name
String grade
String stars
String length
//String extra
//String number
String page
String fa
public String getGradeSort()
String toString()
}