Implemented the generator program

This commit is contained in:
Kohsuke Kawaguchi 2014-03-21 17:13:20 -07:00
parent 93cbf3b558
commit ae375b93de
5 changed files with 70 additions and 5 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
output

63
build.groovy Normal file
View File

@ -0,0 +1,63 @@
// generate actual message files
def dir = new File("output");
dir.deleteDir()
dir.mkdir()
def xml = new XmlSlurper().parse("messages.xml")
def dt = new Date()
dt = "${dt.year+1900}Q${1+((int)dt.month/3)}"
def slots = xml.slots.find{ it.@time==dt }
int s = 0;
def messageCounts = [];
if (slots!=null) {
slots.slot.each { slot ->
for (int i=0; i<((slot.@weight?.text() ?: 1) as int); i++) {// repeat for each weight of each slot
int m = 0;
slot.message.each { msg ->
generate(msg, "output/message-${s}_${m}.html");
m++;
}
messageCounts << m;
s++;
}
}
}
new File("output/message.html").text = new File("message.html").text.replace("[1,1,2]",messageCounts.toString());
def generate(msg,name) {
def caption = msg.caption.text()
def link = msg.link.text()
def blurb = msg.blurb.text()
def logo = msg.logo.text()
def linkText = link;
if (linkText.startsWith("https://")) linkText=linkText.substring(8);
if (linkText.startsWith("http://")) linkText=linkText.substring(7);
new File(name).text = """
<html>
<link rel="stylesheet" type="text/css" href="../patron.css">
<body style="margin:0">
<div id="patron">
<div style="float:right;">
<a class=ourl href="${link}">
<img class=logo src="${logo}">
</a>
</div>
<div class=inner>
<div class="color"><a href="${link}" id=ocaption class=ourl>${caption}</a></div>
<div class="color"><a href="${link}" id=olink class=ourl>${linkText}</a></div>
<div id=oblurb>${blurb}</div>
</div>
</div>
</body>
</html>
"""
}

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<patrons>
<slots time="2014Q1"><!-- test slot -->
<slot>
<slot weight="2">
<contact>lwells@cloudbees.com</contact>
<message>
<caption>Bring JenkinsCI to the Enterprise with CloudBees</caption>
<link>http://www.cloudbees.com/jenkins</link>
<blurb>Amp up your Jenkins with professional support, enterprise plugins, and a multi-master operations center$B!D(B and get Jenkins in the cloud</blurb>
<blurb>Amp up your Jenkins with professional support, enterprise plugins, and a multi-master operations center... and get Jenkins in the cloud</blurb>
<logo>https://www.cloudbees.com/sites/default/files/images/CB-logo-clr.R-square78x78.png</logo>
</message>
</slot>
<!-- 3 more slots unused -->
<slot>
<contact>kk@kohsuke.org</contact>
@ -26,5 +26,7 @@
<logo>https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png</logo>
</message>
</slot>
<!-- 1 slot unused -->
</slots>
</patrons>

View File

@ -2,7 +2,6 @@
width:568px;
height:75px;
overflow:hidden;
border:1px solid black;
font-family: Verdana, arial, sans-serif;
}
#patron .inner {

View File

@ -31,7 +31,7 @@
... and preview it here:
</p>
<div id="patron">
<div id="patron" style="border:1px solid black;">
<div style="float:right;">
<a class=ourl>
<img class=logo>