# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
html_handler = (args, out, request, url_parts) ->
fs.readFile 'index.html', 'utf8', (err, data) ->
if err
html_handler = (args, out, request, url_parts) ->
fs.readFile 'index.html', 'utf8', (err, data) ->
if err
str = str.replace clean_pathname_regex2, '/_'
return str.replace clean_pathname_regex3, '_'
str = str.replace clean_pathname_regex2, '/_'
return str.replace clean_pathname_regex3, '_'
-# serve javascript files from within /usr/share/javascript
-javascript_handler = (args, out, request, url_parts) ->
- filename = clean_pathname "/usr/share/#{url_parts.pathname}"
+# serve javascript files from within external/
+external_javascript_handler = (args, out, request, url_parts) ->
+ filename = clean_pathname "external/#{url_parts.pathname.substr 10}"
fs.readFile filename, 'utf8', (err, data) ->
if err
out.writeHead 404
fs.readFile filename, 'utf8', (err, data) ->
if err
out.writeHead 404
- if rel_path.substr(0, 11) is 'javascript/'
- return javascript_handler url_parts.query, res, req, url_parts
+ if rel_path.substr(0, 9) is 'external/'
+ return external_javascript_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 4) is '.css'
res.writeHead 200, 'Content-Type': 'text/css'
return css_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 3) is '.js'
res.writeHead 200, 'Content-Type': 'text/javascript'
return js_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 4) is '.css'
res.writeHead 200, 'Content-Type': 'text/css'
return css_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 3) is '.js'
res.writeHead 200, 'Content-Type': 'text/javascript'
return js_handler url_parts.query, res, req, url_parts
query[key] = parg
return set_handler query, res, req, url_parts
return
query[key] = parg
return set_handler query, res, req, url_parts
return
return get_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 4) is '.ico'
res.writeHead 404
return get_handler url_parts.query, res, req, url_parts
else if rel_path.substr(rel_path.length - 4) is '.ico'
res.writeHead 404
return html_handler url_parts.query, res, req, url_parts
return html_handler url_parts.query, res, req, url_parts