- CCT Public Page
- [CCT Members Area]
import com.atlassian.confluence.pages.Page;
import bucket.container.ContainerManager;
def index = request.getSession(true).getServletContext().getAttribute("climb.index")
if (index == null )
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.
Stars |
Name Starts With |
Name Contains |
Grade |
Area |
Sort By |
---|---|---|---|---|---|
\\\\
'''
def filtered = new ArrayList();
for (c in index.climbs)
{
if ( pages.contains(c.page) && grades.contains(c.grade) && stars.contains(c.stars) )
{
if (nameContains==null || nameContains.length()==0 || c.name.toLowerCase().contains(nameContains.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.startsWith(g) )
}
}
}
}
if (sortBy!=null && !sortBy.equals("none"))
{
def comparator = new Comparator(){
int compare(a,b)
}
//def sorter =
if (sortBy.equals(totalSorts[0]))
{
//out.println "sorting by grade"
//sorter = { }
def comparator = new Comparator(){
int compare(a,b)
}
}
//out.println "sorting"
filtered.sort comparator
}
out.println "h2. Results"
out.println filtered.size + " results"
out.println "|| || Stars || Name || Length || Grade || Area ||"
for (c in filtered)
{
out.println "| | " + " | " + c.name + " | " + c.length + " | " + c.grade + " | [" + c.page + "] |"
//response.flushBuffer()
}
def addChildren(Page page, Index index)
{
for (child in page.sortedChildren)
}
def doPage (Page page, Index index)
{
int index1 = page.content.indexOf("
String xml = page.content.substring(index1+7, index2)
//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
{
def ret = []
for (c in x)
ret.add c
return ret
}
class Index
{
List climbs = []
List pages = []
}
class Climb
{
String name
String grade
String stars
String length
//String extra
//String number
String page;
String getGradeSort()
String toString()
}