Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Latest commit

 

History

History
46 lines (29 loc) · 2.06 KB

README.md

File metadata and controls

46 lines (29 loc) · 2.06 KB

99 bottles of beer lyrics in Apache Sling

proposal for a candidate of http://99-bottles-of-beer.net leveraging:

mvn clean install content-package

in gogo shell, run the following command that parses the website and creates /var/bottles tree

run egrep 'http://99-bottles-of-beer.net/lyrics.html' @ name bottles @ with 'pattern=(?<number>\d(\d)?) bottle(s)? of beer on the wall,' / mkdir '/var/bottles/${bottles.number}' / write 'onTheWall=${bottles.number}' 'offTheWall=${Number(bottles.number)-1}' 'sling:resourceType=bottles/line'

in your favourite groovy console, run the following groovy script, build a list pipe like this one:

def plumber = getService("org.apache.sling.pipes.Plumber");

plumber.newPipe(resourceResolver)
  .echo("/var")
  .children('sling:Folder#bottles')
  .$('[sling:resourceType=bottles/line]').name("line")
  .outputs("On the Wall!",'${line.onTheWall}')
  .build("/services/adapt/list");

check that list pipe is working my running following queries:

GET /services/adapt/list.csv?size=99

GET /services/adapt/list.json

now, back in gogo, add a subnode to describe the song component how to search for lines

run mkdir /var/bottles/pipes/lines / write "sling:resourceType=slingPipes/reference" "expr=/services/adapt/list"

still in gogo run that command that will set resource type of the song, allow access to user imccoy, and package up bottles for safety

run echo /var/bottles / write 'sling:resourceType=bottles/song' / allow imccoy / pkg /etc/packages/bottles-backup.zip

Now enjoy the lyrics of the song by accessing

GET /var/bottles.html