Skip to content

Commit

Permalink
Merge branch 'release/2.0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 29, 2018
2 parents b8a423b + 1ef0194 commit f2db665
Show file tree
Hide file tree
Showing 12 changed files with 1,692 additions and 495 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="2.0.10"></a>
## [2.0.10](https://github.com/poppinss/youch/compare/v2.0.9...v2.0.10) (2018-09-29)


### Features

* **links:** add support for font awesome icons and lazy load css files ([1bd258a](https://github.com/poppinss/youch/commit/1bd258a))



<a name="2.0.9"></a>
## [2.0.9](https://github.com/poppinss/youch/compare/v2.0.8...v2.0.9) (2018-08-11)

Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,33 @@ http.createServer(function (req, res) {
}).listen(8000)
```

## Adding helpful links
Everytime an error occurs, we can help users we letting search for the error on Google, over even on the Github repo of our project.

Youch let you define clickable links to redirect the user to a website with the error message.

```js
youch
.addLink(({ message }) => {
const url = `https://stackoverflow.com/search?q=${encodeURIComponent(`[adonis.js] ${message}`)}`
return `<a href="${url}" target="_blank" title="Search on stackoverflow">Search stackoverflow</a>`
})
.toHTML()
```

Also you can make use of [Font awesome brands icons](https://fontawesome.com/icons?d=gallery&s=brands&m=free) to display icons.

**If you will use fontawesome icons, then Youch will automatically load the CSS files from the font awesome CDN for you.**

```js
youch
.addLink(({ message }) => {
const url = `https://stackoverflow.com/search?q=${encodeURIComponent(`[adonis.js] ${message}`)}`
return `<a href="${url}" target="_blank" title="Search on stackoverflow"><i class="fab fa-stack-overflow"></i></a>`
})
.toHTML()
```

## Release History
Checkout [CHANGELOG.md](CHANGELOG.md) file for release history.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
test_script:
- node --version
- npm --version
- npm run test:win
- npm run test

build: off
clone_depth: 1
Expand Down
14 changes: 7 additions & 7 deletions bin/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ let templateSource = fs.readFileSync(absPath('error.mustache'), 'utf-8')
*/
function bundleJsFiles () {
return concat(jsFiles)
.then((output) => {
const uglified = UglifyJS.minify(output)
if (uglified.error) {
throw new Error(uglified.error)
}
return uglified.code
})
.then((output) => {
const uglified = UglifyJS.minify(output)
if (uglified.error) {
throw new Error(uglified.error)
}
return uglified.code
})
}

/**
Expand Down
25 changes: 15 additions & 10 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ http.createServer((req, res) => {
}

youch
.toHTML()
.then((response) => {
res.writeHead(200, {'content-type': 'text/html'})
res.write(response)
res.end()
}).catch((error) => {
res.writeHead(500)
res.write(error.message)
res.end()
})
.addLink(({ message }) => {
const url = `https://stackoverflow.com/search?q=${encodeURIComponent(`[adonis.js] ${message}`)}`
return `<a href="${url}" target="_blank" title="Search on stackoverflow"><i class="fab fa-stack-overflow"></i>
</a>`
})
.toHTML()
.then((response) => {
res.writeHead(200, { 'content-type': 'text/html' })
res.write(response)
res.end()
}).catch((error) => {
res.writeHead(500)
res.write(error.message)
res.end()
})
}).listen(8000, () => {
console.log('listening to port 8000')
})
Loading

0 comments on commit f2db665

Please sign in to comment.