Commit 09129e47 authored by Leo Iannacone's avatar Leo Iannacone

Merge remote-tracking branch 'github/sbuild' into sbuild

parents 3b88a98c 994d5513
...@@ -7,6 +7,7 @@ io = require("socket.io")(server) ...@@ -7,6 +7,7 @@ io = require("socket.io")(server)
serve_static = require("serve-static") serve_static = require("serve-static")
serve_index = require("serve-index") serve_index = require("serve-index")
compression = require("compression")
errorhandler = require("errorhandler") errorhandler = require("errorhandler")
routes = require("../routes") routes = require("../routes")
...@@ -24,6 +25,9 @@ if env is "development" ...@@ -24,6 +25,9 @@ if env is "development"
else else
app.use(errorhandler()) app.use(errorhandler())
# use compression by default
app.use(compression())
# the views # the views
app.set("views", __dirname + "/../views") app.set("views", __dirname + "/../views")
app.set("view engine", "ejs") app.set("view engine", "ejs")
...@@ -66,6 +70,15 @@ if config.routes.debomatic ...@@ -66,6 +70,15 @@ if config.routes.debomatic
res.set('Content-Type', 'text/plain') res.set('Content-Type', 'text/plain')
next() next()
# always download log files and some source files, like .dsc and .changes ones
app.all config.routes.debomatic + '/:distribution/pool/:package/:file', (req, res, next) ->
type = utils.file_type(req.params.file)
ext = req.params.file.split('.').pop()
if type is "log" or ext in ["changes", "dsc"]
res.set('Content-Type', 'text/plain')
res.set('Content-Disposition', 'attachment; filename=' + req.params.file)
next()
app.use(config.routes.debomatic, serve_static(config.debomatic.path)) app.use(config.routes.debomatic, serve_static(config.debomatic.path))
app.use(config.routes.debomatic, serve_index(config.debomatic.path, app.use(config.routes.debomatic, serve_index(config.debomatic.path,
{view: "details", icons: true})) {view: "details", icons: true}))
...@@ -73,9 +86,6 @@ if config.routes.debomatic ...@@ -73,9 +86,6 @@ if config.routes.debomatic
# serve stylesheet-javascript # serve stylesheet-javascript
app.use(serve_static(__dirname + "/../public")) app.use(serve_static(__dirname + "/../public"))
# serve dsc files as octet-stream
serve_static.mime.define("application/octet-stream": ["dsc"])
# Listening # Listening
server.listen config.port, config.host, null, (err) -> server.listen config.port, config.host, null, (err) ->
......
...@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) -> ...@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) ->
config.routes.debomatic) config.routes.debomatic)
file.orig_name = f file.orig_name = f
file.name = f.split("_")[0] file.name = f.split("_")[0]
if file.extension in ["deb", "ddeb", "udeb"] type = utils.file_type(f)
if type is "deb"
data.package.debs.push(file) data.package.debs.push(file)
else if file.extension in ["changes", "dsc"] or f.indexOf('.tar.') > 0 or f.indexOf('.diff.') > 0 else if type is "source"
file.name = f.replace(data.package.orig_name + ".", "") file.name = f.replace(data.package.orig_name + ".", "")
if file.extension is "changes" if file.extension is "changes"
file.name = f.split('_').pop() file.name = f.split('_').pop()
......
...@@ -37,8 +37,8 @@ config.debomatic.jsonfile = "/var/log/debomatic-json.log" ...@@ -37,8 +37,8 @@ config.debomatic.jsonfile = "/var/log/debomatic-json.log"
Web template configuration Web template configuration
Title and description for the header Title and description for the header
### ###
config.web.debomatic.architecture = "amd64" config.web.debomatic.architecture = "system" # or amd64, i386, ...
config.web.title = "Deb-o-Matic " + config.web.debomatic.architecture config.web.title = "Deb-o-Matic"
### ###
Admin email and name to show in the home page. Admin email and name to show in the home page.
...@@ -164,6 +164,12 @@ try ...@@ -164,6 +164,12 @@ try
crypto.createHash("sha256") crypto.createHash("sha256")
.update(config.debomatic.path) .update(config.debomatic.path)
.digest("hex") .digest("hex")
if config.web.debomatic.architecture == "system"
check = "dpkg-architecture -qDEB_BUILD_ARCH"
require("child_process").exec check, (error, stdout, stderr) ->
config.web.debomatic.architecture = stdout.trim()
module.exports = config module.exports = config
catch err catch err
......
...@@ -117,6 +117,14 @@ errors_handler = (from, err, socket) -> ...@@ -117,6 +117,14 @@ errors_handler = (from, err, socket) ->
socket.emit config.events.error, msg if socket socket.emit config.events.error, msg if socket
return return
file_type = (filename) ->
extension = filename.split(".").pop()
if extension in ["deb", "ddeb", "udeb"]
return "deb"
if extension in ["changes", "dsc"] or filename.indexOf('.tar.') > 0 or filename.indexOf('.diff.') > 0
return "source"
return "log"
Tail::watchEvent = (e) -> Tail::watchEvent = (e) ->
_this = this _this = this
if e is "change" if e is "change"
...@@ -152,5 +160,6 @@ module.exports.get_file_path = get_file_path ...@@ -152,5 +160,6 @@ module.exports.get_file_path = get_file_path
module.exports.get_files_list = get_files_list module.exports.get_files_list = get_files_list
module.exports.watch_path_onsocket = watch_path_onsocket module.exports.watch_path_onsocket = watch_path_onsocket
module.exports.errors_handler = errors_handler module.exports.errors_handler = errors_handler
module.exports.file_type = file_type
module.exports.arrayEqual = arrayEqual module.exports.arrayEqual = arrayEqual
module.exports.Tail = Tail module.exports.Tail = Tail
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"serve-index": "*", "serve-index": "*",
"serve-static": "*", "serve-static": "*",
"errorhandler ": "*", "errorhandler ": "*",
"compression": "*",
"ejs": "1.*", "ejs": "1.*",
"socket.io": "1.2.*", "socket.io": "1.2.*",
"tail": "*", "tail": "*",
......
...@@ -353,7 +353,7 @@ function Page_Distrubion(socket) { ...@@ -353,7 +353,7 @@ function Page_Distrubion(socket) {
if ($tags.length > 0) if ($tags.length > 0)
$size.insertBefore($tags); $size.insertBefore($tags);
else else
$file.append($size); $file.find("a").append($size);
} }
}; };
......
...@@ -127,7 +127,7 @@ function Page_Generic() { ...@@ -127,7 +127,7 @@ function Page_Generic() {
}; };
this.preferences = function () { this.preferences = function () {
var bootstrap_theme_css = '/external_libs/bootstrap-3.2.0/css/bootstrap-theme.min.css'; var bootstrap_theme_css = '/external_libs/bootstrap-3.3.2/css/bootstrap-theme.min.css';
if (config.preferences.glossy_theme) { if (config.preferences.glossy_theme) {
if ($('head').find('link[href="' + bootstrap_theme_css + '"]').length === 0) if ($('head').find('link[href="' + bootstrap_theme_css + '"]').length === 0)
$('head').append('<link rel="stylesheet" href="' + bootstrap_theme_css + '">'); $('head').append('<link rel="stylesheet" href="' + bootstrap_theme_css + '">');
......
...@@ -10,21 +10,21 @@ get_github() { ...@@ -10,21 +10,21 @@ get_github() {
ARCHIVE=v${VERSION}.zip ARCHIVE=v${VERSION}.zip
URL="https://github.com/${USER}/${NAME}/archive/${ARCHIVE}" URL="https://github.com/${USER}/${NAME}/archive/${ARCHIVE}"
LIB_NAME="${NAME}-${VERSION}" LIB_NAME="${NAME}-${VERSION}"
if [ -d ${EXT_LIBS_DIR}/${LIB_NAME} ] ; then return ; fi if [ -d "${EXT_LIBS_DIR}/${LIB_NAME}" ] ; then return ; fi
echo "Downloading ${NAME} ${VERSION} ..." echo "Downloading ${NAME} ${VERSION} ..."
curl -s -O -L ${URL} && \ curl -s -O -L "${URL}" && \
unzip -q ${ARCHIVE} && rm ${ARCHIVE} unzip -q "${ARCHIVE}" && rm "${ARCHIVE}"
if [ "$DIST" != "" ] ; then if [ "${DIST}" != "" ] ; then
mv ${LIB_NAME} tmp mv "${LIB_NAME}" tmp
mv tmp/${DIST} ${LIB_NAME} mv "tmp/${DIST}" "${LIB_NAME}"
rm -r tmp rm -r tmp
fi fi
} }
get_bootstrap() { get_bootstrap() {
VERSION="3.2.0" VERSION="3.3.2"
NAME="bootstrap-${VERSION}-dist" NAME="bootstrap-${VERSION}-dist"
if [ -d ${EXT_LIBS_DIR}/${NAME} ] ; then return ; fi if [ -d "${EXT_LIBS_DIR}/${NAME}" ] ; then return ; fi
ARCHIVE=${NAME}.zip ARCHIVE=${NAME}.zip
URL="https://github.com/twbs/bootstrap/releases/download/v${VERSION}/${ARCHIVE}" URL="https://github.com/twbs/bootstrap/releases/download/v${VERSION}/${ARCHIVE}"
echo "Downloading bootstrap ${VERSION} ..." echo "Downloading bootstrap ${VERSION} ..."
...@@ -35,7 +35,7 @@ get_bootstrap() { ...@@ -35,7 +35,7 @@ get_bootstrap() {
get_jquery() { get_jquery() {
VERSION="1.11.0" VERSION="1.11.0"
DIR_JQUERY="jquery" DIR_JQUERY="jquery"
if [ -d ${EXT_LIBS_DIR}/${DIR_JQUERY} ] ; then return ; fi if [ -d "${EXT_LIBS_DIR}/${DIR_JQUERY}" ] ; then return ; fi
mkdir ${DIR_JQUERY} mkdir ${DIR_JQUERY}
cd ${DIR_JQUERY} cd ${DIR_JQUERY}
URL="http://code.jquery.com/jquery-${VERSION}.min.js" URL="http://code.jquery.com/jquery-${VERSION}.min.js"
...@@ -45,30 +45,32 @@ get_jquery() { ...@@ -45,30 +45,32 @@ get_jquery() {
} }
get_tablesorter() { get_tablesorter() {
VERSION="2.17.8"
DIR_TABLESORTER="tablesorter" DIR_TABLESORTER="tablesorter"
if [ -d ${EXT_LIBS_DIR}/${DIR_TABLESORTER} ] ; then return ; fi if [ -d "${EXT_LIBS_DIR}/${DIR_TABLESORTER}" ] ; then return ; fi
mkdir ${DIR_TABLESORTER} mkdir ${DIR_TABLESORTER}
cd ${DIR_TABLESORTER} cd ${DIR_TABLESORTER}
echo "Downloading tablesorter ..." echo "Downloading tablesorter ..."
curl -s -O -L "http://mottie.github.io/tablesorter/js/jquery.tablesorter.min.js" BASE="https://raw.githubusercontent.com/Mottie/tablesorter/v${VERSION}"
curl -s -O -L "http://mottie.github.io/tablesorter/js/jquery.tablesorter.widgets.min.js" curl -s -O -L "${BASE}/js/jquery.tablesorter.min.js"
curl -s -O -L "http://mottie.github.io/tablesorter/css/theme.bootstrap.css" curl -s -O -L "${BASE}/js/jquery.tablesorter.widgets.min.js"
curl -s -O -L "${BASE}/css/theme.bootstrap.css"
cd .. cd ..
} }
if [ ! -d ${EXT_LIBS_DIR} ] ; then mkdir -p ${EXT_LIBS_DIR} ; fi if [ ! -d "${EXT_LIBS_DIR}" ] ; then mkdir -p "${EXT_LIBS_DIR}" ; fi
TMP_DIR="`mktemp -d`" TMP_DIR="$(mktemp -d)"
cd ${TMP_DIR} cd "${TMP_DIR}"
get_jquery get_jquery
get_tablesorter get_tablesorter
# get boostrap # get boostrap
get_github "twbs" "bootstrap" "3.2.0" "dist" get_github "twbs" "bootstrap" "3.3.2" "dist"
# get chartist # get chartist
get_github "gionkunz" "chartist-js" "0.7.2" "dist" get_github "gionkunz" "chartist-js" "0.7.2" "dist"
if [ "`ls -1`" != "" ] ; then mv * ${EXT_LIBS_DIR} ; fi if [ "$(ls -1)" != "" ] ; then mv ./* "${EXT_LIBS_DIR}" ; fi
cd && rm -r ${TMP_DIR} cd && rm -r "${TMP_DIR}"
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<script src="/external_libs/jquery/jquery-1.11.0.min.js"></script> <script src="/external_libs/jquery/jquery-1.11.0.min.js"></script>
<script src="/external_libs/tablesorter/jquery.tablesorter.min.js"></script> <script src="/external_libs/tablesorter/jquery.tablesorter.min.js"></script>
<script src="/external_libs/tablesorter/jquery.tablesorter.widgets.min.js"></script> <script src="/external_libs/tablesorter/jquery.tablesorter.widgets.min.js"></script>
<script src="/external_libs/bootstrap-3.2.0/js/bootstrap.min.js"></script> <script src="/external_libs/bootstrap-3.3.2/js/bootstrap.min.js"></script>
<script src="/external_libs/chartist-js-0.7.2/chartist.min.js"></script> <script src="/external_libs/chartist-js-0.7.2/chartist.min.js"></script>
<script> <script>
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.png" /> <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.png" />
<title><%= web.title %></title> <title><%= web.title %> <%= web.debomatic.architecture %></title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/external_libs/bootstrap-3.2.0/css/bootstrap.min.css"> <link rel="stylesheet" href="/external_libs/bootstrap-3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="/external_libs/bootstrap-3.2.0/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="/external_libs/bootstrap-3.3.2/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="/external_libs/chartist-js-0.7.2/chartist.min.css"> <link rel="stylesheet" href="/external_libs/chartist-js-0.7.2/chartist.min.css">
<link rel="stylesheet" href="/external_libs/tablesorter/theme.bootstrap.css"> <link rel="stylesheet" href="/external_libs/tablesorter/theme.bootstrap.css">
<link rel="stylesheet" href="/stylesheets/style.css?<%= version %>"> <link rel="stylesheet" href="/stylesheets/style.css?<%= version %>">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment