webbuild: support for suggesting specfile name and version when creating a new package

- also remove .spec from spec edit dropdown
This commit is contained in:
Silvan Calarco 2013-05-19 16:54:31 +02:00
parent 91ad537c95
commit c1617df152
2 changed files with 44 additions and 7 deletions

View File

@ -31,6 +31,41 @@ function checkEnter(event) {
return false;
}
function suggestSpecName(url) {
var url=document.getElementById("speccreateurl").value;
if (url.indexOf('&') > 0) url=url.substring(0,url.indexOf('&')+1);
var filename=url.substring(url.lastIndexOf('/')+1);
if (filename.indexOf('.') > 0) filename=filename.substring(0,filename.indexOf('.'));
if (filename.lastIndexOf('-') > 0) {
var version=filename.substring(filename.lastIndexOf('-')+1);
filename=filename.substring(0,filename.lastIndexOf('-')).toLowerCase();
}
document.getElementById("speccreateurl").value=url;
document.getElementById("speccreatename").value=filename;
document.getElementById("speccreateversion").value=version;
if (filename) {
document.getElementById("speccreatebutton").disabled=false;
} else {
document.getElementById("speccreatebutton").disabled=true;
}
if (filename.search("perl-") >= 0) {
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
if (document.getElementById("speccreatetype").options[j].value == "perl")
document.getElementById("speccreatetype").options[j].selected=true;
};
} else if (filename.search("python-") >= 0) {
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
if (document.getElementById("speccreatetype").options[j].value == "python")
document.getElementById("speccreatetype").options[j].selected=true;
};
} else {
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
if (document.getElementById("speccreatetype").options[j].value == "library")
document.getElementById("speccreatetype").options[j].selected=true;
};
}
}
function replaceHTML(el, html) {
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
/*@cc_on // Pure innerHTML is slightly faster in IE

View File

@ -547,12 +547,12 @@ elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchm
echo -n "onchange=ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&REQUEST=changespec\");>"
echo -n "<option value=\"\">-- Select a .spec file --</option>"
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec | sort -f" | while read f; do
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec | sed \"s|.spec$||\" | sort -f" | while read f; do
specname=${f/.spec}
[ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED=
echo -n "<option value=\"$specname\" $SELECTED>${specname}.spec</option>"
echo -n "<option value=\"$specname\" $SELECTED>${specname}</option>"
done
echo -n "</select>]]></specedit>"
echo -n "</select>.spec]]></specedit>"
fi
[ "$PACKAGE" -a ! "$REQUEST" ] && REQUEST=edit
@ -695,7 +695,9 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
#(getElementById('package').selectedIndex);>"
echo "<option value=\"\">-- Select a SRPM package --</option>"
SRPMBUTTONDISABLED="disabled=disabled"
ls $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm | sort -f > $WEBBUILD_STATEDIR/cache/repository-src-$REPOSITORY
if [ $local_ftp/$REPOSITORY/SRPMS.base -nt $WEBBUILD_STATEDIR/cache/repository-src-$REPOSITORY ]; then
ls $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm | sort -f > $WEBBUILD_STATEDIR/cache/repository-src-$REPOSITORY
fi
while read f; do
[ -r $f ] || continue
pkgname=`basename $f`
@ -740,17 +742,17 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
# SPECFILE creation
if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -a "$MAINTAINERMODE" != "true" ]; then
echo -n "<speccreate><![CDATA[<div style=\"white-space:nowrap;\">"
echo -n " Start from URL:<input type=text id=speccreateurl value=\"\" style=\"width:32%\">"
echo -n " Start from URL:<input onChange=\"suggestSpecName()\" type=text id=speccreateurl value=\"\" style=\"width:32%\">"
echo -n " name:<input type=text id=speccreatename value=\"\" style=\"width:10%\">"
echo -n " type:<select id=speccreatetype>"
for t in `ls /usr/share/autospec/templates`; do
[ "$t" = "library" ] && SELECTED="selected=selected" || SELECTED=
echo -n "<option value=\"$t\" $SELECTED>$t</option>"
echo -n "<option id=speccreatetype value=\"$t\" $SELECTED>$t</option>"
done
echo -n "</select>"
echo -n " version:<input type=text id=speccreateversion value=\"\" style=\"width:5%\">"
echo -n " branch:<input type=text id=speccreategitbranch value=\"\" style=\"width:5%\">"
echo -n "<input type=button id=speccreatebutton value=\"Create .spec\" onclick=ajax_getvalues(\""
echo -n "<input type=button disabled id=speccreatebutton value=\"Create .spec\" onclick=ajax_getvalues(\""
echo -n "REQUEST=speccreate&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGE=\"+encodeURIComponent(getElementById('speccreatename').value)+\"&"
echo -n "SPECCREATETYPE=\"+getElementById('speccreatetype').value+\"&"