- 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.indexi5")
if (index == null )
def totalStars = ["","*","**","***"]
def totalGrades = ["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 =["29","30","31","32","33","34","V10","V11","V12","V13","V14","V15"]
def stars =totalStars 
def pages = null
def nameStartsWith = ""
def nameContains = ""
out.println "h2. Sport"
showList(["29","30","31","32","33","34"], false, index)
out.println "h2. Trad"
showList(["26","27","28", "29","30","31","32","33","34"], true, index)
out.println "h2. Bouldering"
showList(["V10","V11","V12","V13","V14","V15"], false, index)
def showList(def grades, boolean onlyTrad, def index)
{
def sortBy = "grade,stars,name"
def totalSorts = ["grade,stars,name","name","none"]
def filtered = new ArrayList();
for (c in index.climbs)
{
  if (  c.grade!=null && grades.contains(c.grade) )
  {
String boltchar = new String( [222] as char[]   ) 
if (!onlyTrad || c.extra==null || (!c.extra.contains("B") && !c.extra.contains(boltchar) && !c.extra.contains("TR") ) )
  }
}
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 || FA || Area ||"
for (c in filtered)
}
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)
    {
      def grade = climb.@grade
      if (grade!=null)
      {
				if (grade.indexOf('/') > 0)
				grade = grade.replace('?', ' ');
				grade = grade.replace('M', ' ');
				grade = grade.replace('A', ' ');
				grade = grade.trim();
				if (grade.indexOf(' ') > 0)
				grade = grade.trim();
      }
      Climb c = new Climb( name: climb.@name , 
grade: grade , 
stars: climb.@stars, 
length: climb.@length, 
fa: climb.@fa,
extra: climb.@extra,
page: page.title)
      c.stars = c.stars==null?"":c.stars
      c.stars = c.stars.trim()
      index.climbs.add( c )
}
  }
  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
    String extra
public String getGradeSort()
String toString()
}