sintaxi / harp Goto Github PK
View Code? Open in Web Editor NEWStatic Web Server/Generator/Bundler
Home Page: http://harpjs.com
Static Web Server/Generator/Bundler
Home Page: http://harpjs.com
How to reproduce:
% harp init myharpproject
% cd myharpproject
% harp compile
% cat www/index.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<h1>Welcome to Harp</h1>
<h3>This is yours to own. Enjoy.</h3>
</body>
</html>
% _
(Line breaks added by me)
Open www/index.html in the browser -> the stylesheet cannot be found.
The URL of the stylesheet is absolute to the "document root" which is not necessarily the case and depends on where you deploy the app to.
Suggestion: replace the absolute URL with URL relative to index.html.
Best regards
Christian
If I visit the local IP and port on my computer or another device while using multihost
, I get
Local server does not support history. Perhaps you are looking for <href='http://192.168.1.io:9966'>http://192.168.1.io:9966</a>.
instead of my app. It works as expected while using server
.
Directory structure:
/public
/index.jade
/getting-started
/index.jade
/page2.jade
When I go to http://localhost:8001/getting-started
the server crashes with this error:
/usr/local/lib/node_modules/harp/lib/middleware.js:44
if (!redirect) return resume();
^
ReferenceError: redirect is not defined
at SendStream.directory (/usr/local/lib/node_modules/harp/lib/middleware.js:44:10)
at SendStream.EventEmitter.emit (events.js:115:20)
at SendStream.redirect (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:271:55)
at SendStream.pipe (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:321:41)
at Object.oncomplete (fs.js:297:15)
It works fine if you go to http://localhost:8001/getting-started/
(with the slash at the end).
Using [email protected]
When there's something broken in my LESS file, it'd be nice if instead of giving me back an html/text response, I get back the error injected in CSS like this:
body:before {
display: block;
content: "There was an error in your CSS, fix it!";
border: #EED3D7 solid 1px;
border-radius: 5px;
color: #B94A48;
background-color: #F2DEDE;
padding: 10px;
margin: 20px;
font-family: monospace;
font-size: 14px;
}
In a data.json
file, you might switch a layout from false
to true
instead of deleting the entire entry:
{
"index": {
"layout": true
}
}
Expected Behaviour
This uses _layout.jade
as a layout it it’s present. (Basically, it’s an explicit way to perform the default behaviour.)
Actual Behaviour
The layout true.jade
is used if it’s present.
My harp.json file only has this:
{}
Using 0.7.0
This is the error I'm getting:
TypeError: Cannot set property 'environment' of undefined
at Object.exports.parseHarpConfig [as handle] (/usr/local/lib/node_modules/harp/lib/middleware.js:112:34)
at next (/usr/local/lib/node_modules/harp/node_modules/connect/lib/proto.js:190:15)
at resume (/usr/local/lib/node_modules/harp/lib/middleware.js:54:5)
at SendStream.error (/usr/local/lib/node_modules/harp/lib/middleware.js:67:35)
at SendStream.EventEmitter.emit (events.js:95:17)
at SendStream.error (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:147:51)
at SendStream.onStatError (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:248:48)
at /usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:320:26
at Object.oncomplete (fs.js:93:15)
Because the actual CSS file is never written to disk when working with LESS, there's no way for me to minify the resulting CSS.
A possible solution would be to specify the output I want in the harp.json
file, but that could be a slippery slope.
// harp.json
{
"config": {
"compress-css": true,
"compress-js": true,
"compress-html": true
}
}
Layouts should walk the directory tree by default looking for _layout.xxx in each directory until it hits the public directory. (specifying a layout file in _data.json) will be how you override this behaviour.
harp init
in this folder ( possibly in a src directory )harp compile --output /path/to/blog
Static files generated into the blog directory ( root of project )
Directory is clobbered instead of added to losing any content you had in it
Using pkg.name
or pkg.version
outside of index.jade
prevents the template from rendering.
The expected behaviour would be that they’re available in any file inside the templates
directory. If this is difficult or inefficient, having them available in a partial I can include everywhere would also work. Ideally, I’d like to be able to use pkg.name
anywhere in the templates “Harp” might be hardcoded.
Using special characters in Jade or Markdown causes the HTML file to end a few characters early. This can cause a loose </
to show up, rendered on the page, prevent tags from closing, etc.
This is possibly a duplicate of issue #40.
Input
!!!
html(lang="en")
head
meta(charset="utf-8")
title= globals.title
body
h1 Should’t “Do This” & more…
Expected Output
(Line breaks are for readability, the HTML compression is working fine.)
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"><title>Harp</title></head>
<body><h1>Should’t “Do This” & more…</h1>
</body>
</html>
Actual Output
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"><title>Harp</title></head>
<body>
<h1>Should’t “Do This” & more…</h1>
If you don’t use the proper characters and reference the special characters instead, the output is as you’d expect:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"><title>Harp</title></head>
<body><h1>Should't "Do This" & more…</h1>
</body>
</html>
If you visit a subdomain without an app while using multihost
, you just get Cannot find project
printed in the browser.
The expected behaviour would be that an error template is used to handle this. Basically, “There’s no app here, but here’s a list of the apps you are currently hosting.”
I'm following the Get Started pages. When I start the server (default settings) I observe two errors. (Previous steps did not display any errors)
I'm on Windows 7. Harp version 0.8.13.
.#===========================================================
.# Harp
.#===========================================================
.# It appears you already have a server
.# listening on this port. You will first
.# have to stop that server to get Harp
.# to listen on this port.
.#===========================================================
What port am I conflicting with? - This is in pipeline mode.
Docs say this is supported, but I'm not seeing the expected result.
Here's the content of test.md (using .markdown returns a 404):
# Welcome to #{ globals.name }
When I navigate to http://localhost:9966/test, #{ globals.name }
is not replaced.
Show me the url where my server is running at when I start it:
$ sudo harp multihost -p 80
Hosting multiple projects at http://harp.nu
Available projects:
- http://docs.harp.nu
- http://hello.harp.nu
$ sudo harp multihost -p 8080
Hosting multiple projects at http://harp.nu:8080
...
$ sudo harp server -p 80
Hosting project at http://harp.nu
$ sudo harp multihost -p 80
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:863:11)
at Server._listen2 (net.js:1008:14)
at listen (net.js:1030:10)
at Server.listen (net.js:1096:5)
at Function.app.listen (/usr/local/lib/node_modules/harp/node_modules/connect/lib/proto.js:229:24)
at Object.exports.multihost (/usr/local/lib/node_modules/harp/lib/index.js:52:5)
at Command.<anonymous> (/usr/local/lib/node_modules/harp/bin/harp:64:10)
at Command.<anonymous> (/usr/local/lib/node_modules/harp/node_modules/commander/index.js:254:8)
at Command.EventEmitter.emit (events.js:98:17)
at Command.parseArgs (/usr/local/lib/node_modules/harp/node_modules/commander/index.js:471:12)
I get this nasty looking error when harp.json file is not present. Can we make it say something nicer?
Error: ENOENT, no such file or directory '/Users/jorge/Projects/three/harp.json'
at Object.fs.openSync (fs.js:338:18)
at Object.fs.openSync (/usr/local/lib/node_modules/harp/node_modules/fs-extra/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js:68:26)
at Object.fs.readFileSync (fs.js:182:15)
at module.exports (/usr/local/lib/node_modules/harp/lib/config.js:7:21)
at Object.module.exports.config [as handle] (/usr/local/lib/node_modules/harp/lib/middleware.js:33:24)
at next (/usr/local/lib/node_modules/harp/node_modules/connect/lib/proto.js:190:15)
at resume (/usr/local/lib/node_modules/harp/node_modules/connect/lib/middleware/static.js:60:7)
at SendStream.error (/usr/local/lib/node_modules/harp/node_modules/connect/lib/middleware/static.js:73:37)
at SendStream.EventEmitter.emit (events.js:115:20)
at SendStream.error (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:147:51)
Everything works fine, but when I use the extends command in Jade, it is considered a syntax error and won''t build
My code is
1| extends _layout
2|
3| block content
4| h1 Hello!
undefined:44
buf.push(attrs({ terse: true, 'src':("master.css" type="text/stylesheet") }, {
^^^^
SyntaxError: Unexpected identifier
at Object.Function (unknown source)
at Object.exports.compile (/usr/local/lib/node_modules/harp/node_modules/jade/lib/jade.js:176:8)
at module.exports.jadeCompiler (/usr/local/lib/node_modules/harp/lib/parsers.js:22:27)
at fs.readFile (fs.js:176:14)
at fs.close (/usr/local/lib/node_modules/harp/node_modules/fs-extra/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js:90:5)
at Object.oncomplete (fs.js:297:15)
I'm just setting up a simple site with one index.html file, visited it from the browser and I get an error:
Error: ENOENT, no such file or directory '/Users/kalv/Development/sites/caliper-landing/public/404.jade'
This is probably due to the web browser looking for a favicon, couldn't confirm because I couldn't see an easy way to set debug mode or something on the CLI.
If it is the favicon, could a default 404 response code be sent back to better handle those that don't have a 404 jade template?
First off, I have to say this looks amazing! The only thing I think it's really lacking is client-side JavaScript compilation and minification. I think browserify would be a match made in heaven! Any chance that we might see support for browserify added? Thanks!
I've installed harp by using the command(s): 'npm install -g harp' and 'sudo npm install harp -g'. It looks like everything's installed within the npm.
But, whenever I enter 'harp', it says '-bash: harp: command not found'. Is it supposed to say that before making a project?
200.xxx behaviour should be identical to 404.xxx
page except it returns a status code of 200
.
The following could be either Stylus or LESS:
body {
background: #f0f;
}
div {
background: #f00;
}
If it’s LESS, it will be compiled as:
body {background: #f0f;}
div {background: #f00;}
If it’s Stylus, it is compressed, but not quite as much:
body {
background: #f0f;
}
div {
background: #f00;
}
Unless this is something being specified by the preprocessor, I would have expected the compression to happen way for both.
Show an error message, either in browser or in terminal, saying that there's a problem with my _data.json or _harp.json files.
It doesn't need to show the details of the error, just saying that there's something wrong with the files would be helpful enough (for now).
harp multihost
only shows apps in folders with a “subdomain.” So, something.cssbrigade.com is valid, but cssbrigade.com isn’t. It has nothing to do with harp being in the name like I had initially said.
As far as I can tell, harp init
doesn’t do anything in 0.8.0 or 0.8.1. If you pass it a project to create, it also ignores that. It still says initialized project at
even though nothing happened.
I tested it with fresh installs of 0.7.10, 0.8.0 and 0.8.1 and it only worked in 0.7.10.
Express defaults the charset as utf-8. That behaviour is being overwritten by Harp APF on these files:
https://github.com/sintaxi/harp/blob/master/lib/middleware.js#L231
https://github.com/sintaxi/harp/blob/master/lib/index.js#L111
Here's a quick test that shows the problem:
/test/apps/basic/public/characters.jade
h1 ‘This page has weird characters’
p À, Á, Â, ¬, ¯, ±, é, É, å, ä, ö
/test/basic.js
:it("should have UTF-8 by default in content type header", function(done){
var agent = superagent.agent()
agent.get('http://localhost:8100/characters').end(function(err, rsp){
rsp.should.have.status(200)
rsp.headers['content-type'].should.include('UTF-8')
rsp.text.should.include('À, Á, Â, ¬, ¯, ±, é, É, å, ä, ö')
done()
})
})
The second assertion passes, but when you look at it in the browser all the characters are messed up. Not sure how to assert for that from Mocha.
The problem seems to be that you're passing 'html' instead of 'text/html' to the charset lookup function. The charset works fine when you replace mime.charsets.lookup(outputType)
with mime.charsets.lookup(mimeType)
on the two files mentioned above.
You could also add mime.charsets.lookup(mimeType)||'utf-8'
to make utf-8 the default, in case the charset lookup returns nothing.
I can publish, but once set I am not able to destroy and restart or reset to a new template. Would be great to support one or the other.
This is the error I get if there's no harp.json
file
Using 0.7.0
Error: ENOENT, no such file or directory '/Users/jorge/Dropbox/HarpPlatform/Apps/blog2.harp.io/harp.json'
at Object.fs.openSync (fs.js:413:18)
at Object.fs.openSync (/usr/local/lib/node_modules/harp/node_modules/fs-extra/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js:68:26)
at Object.fs.readFileSync (fs.js:270:15)
at Object.exports.parseHarpConfig [as handle] (/usr/local/lib/node_modules/harp/lib/middleware.js:85:21)
at next (/usr/local/lib/node_modules/harp/node_modules/connect/lib/proto.js:190:15)
at resume (/usr/local/lib/node_modules/harp/lib/middleware.js:54:5)
at SendStream.error (/usr/local/lib/node_modules/harp/lib/middleware.js:67:35)
at SendStream.EventEmitter.emit (events.js:95:17)
at SendStream.error (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:147:51)
at SendStream.onStatError (/usr/local/lib/node_modules/harp/node_modules/connect/node_modules/send/lib/send.js:248:48)
.hbs
.Specifying a layout in _data.json will be how to override the implicit layout behaviour and this file path should be relative to the template file. This makes sense because the _data.json file lives where the template file lives.
This issue from Trevor O.
https://gist.github.com/trevoro/5192f2225b9bc102a844
The only way to validate that your template works in Harp Platform is to compile the template and see if it shows any errors.
It'd be better to have a validate
option to take care of that for you.
$ harp -validate
OK
$ harp -validate
{
"status": 400,
"message": "Template Render Error",
"dump": {
"path": "/Users/jorge/Dropbox/harp.io/apps/jorge.harp.io/public/index.jade"
}
}
$ harp
...
validate [path] checks if project compiles correctly
...
Both about.html and about/index.html are served from public/about.jade (or .markdown), but harp compile
only generates about.html.
.ts
.Using special characters in a LESS or Stylus file causes the end of the CSS file to get cut off a few characters early.
Input
q
quotes: "“" "”" "‘" "’"
body
background: #FF00AA
Expected Output
q {
quotes: "“" "”" "‘" "’";
}
body {
background: #FF00AA;
}
Actual Output
q {
quotes: "“" "”" "‘" "’";
}
body {
background:
When I have too many files, I can’t compile them right now. It doesn’t seem to impact harp server
, just harp compile
. This is the error I got:
Error: EMFILE, too many open files
at ncp.ncp (/usr/local/lib/node_modules/harp/node_modules/fs-extra/node_modules/ncp/lib/ncp.js:12:26)
at Object.copy (/usr/local/lib/node_modules/harp/node_modules/fs-extra/lib/copy.js:34:7)
at exports.compile.copyFile (/usr/local/lib/node_modules/harp/lib/index.js:191:13)
at /usr/local/lib/node_modules/harp/node_modules/mkdirp/index.js:38:26
at Object.oncomplete (fs.js:297:15)`
On http://harpjs.com/docs/development/layout yield
is misspelled the _layout.jade example
When you compile your app, Harp creates every Stylus file as an individual CSS file in addition to importing them.
It doesn’t render the variables in these files, which is presumably related.
If I have main.styl
and import something.styl
, on compile I’ll end up with main.css
and something.css
(instead of just main.css
). The main.css
file will have everything, but if I used a variable from main.css
in something.css
, it will render as plain text instead of the value.
I tested this a bunch and can share my test app with you if you want.
When using the server, everything seems to be in order.
I have two files:
bar.less
body {
background: #000;
}
foo.less
@import bar.less
body {
border: red solid 10px;
}
Expected behaviour: The body will render a black background with a 10px red border
Current behaviour: The CLI breaks outputting the following error:
/usr/local/lib/node_modules/harp/node_modules/less/lib/less/parser.js:418
else throw new(LessEr
^
[object Object]
For example, if you point to a *-min.js
or *.min.js
and the is no matching file, then harp should use YUICompressor on the equivalent non-minified file. There should also be a command line option for disabling/enabling the compression feature for the harp compile
command.
I'd really like to see support for embedded coffeescript
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.