-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from IMBurbank/glitch
ππ Updated with Glitch - v1.0.0
- Loading branch information
Showing
9 changed files
with
365 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"optOut": false, | ||
"lastUpdateCheck": 1501191448412 | ||
"lastUpdateCheck": 1501952465958 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
{"name":"drag-in-files.svg","date":"2016-10-22T16:17:49.954Z","url":"https://cdn.hyperdev.com/drag-in-files.svg","type":"image/svg","size":7646,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/drag-in-files.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(102, 153, 205)","uuid":"adSBq97hhhpFNUna"} | ||
{"name":"click-me.svg","date":"2016-10-23T16:17:49.954Z","url":"https://cdn.hyperdev.com/click-me.svg","type":"image/svg","size":7116,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/click-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(243, 185, 186)","uuid":"adSBq97hhhpFNUnb"} | ||
{"name":"paste-me.svg","date":"2016-10-24T16:17:49.954Z","url":"https://cdn.hyperdev.com/paste-me.svg","type":"image/svg","size":7242,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/paste-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(42, 179, 185)","uuid":"adSBq97hhhpFNUnc"} | ||
{"name":"favicon.ico","date":"2017-08-05T19:31:39.799Z","url":"https://cdn.glitch.com/5c795a21-9bc7-4a14-9c9d-409f90b57ca0%2Ffavicon.ico","type":"image/x-icon","size":32038,"imageWidth":64,"imageHeight":64,"thumbnail":"https://cdn.glitch.com/5c795a21-9bc7-4a14-9c9d-409f90b57ca0%2Ffavicon.ico","thumbnailWidth":64,"thumbnailHeight":64,"dominantColor":null,"uuid":"31cUfarDYCUSu1bV"} | ||
{"uuid":"adSBq97hhhpFNUna","deleted":true} | ||
{"uuid":"adSBq97hhhpFNUnb","deleted":true} | ||
{"uuid":"adSBq97hhhpFNUnc","deleted":true} | ||
{"uuid":"31cUfarDYCUSu1bV","deleted":true} | ||
{"name":"favicon.ico","date":"2017-08-05T19:44:40.101Z","url":"https://cdn.glitch.com/5c795a21-9bc7-4a14-9c9d-409f90b57ca0%2Ffavicon.ico","type":"image/x-icon","size":32038,"imageWidth":64,"imageHeight":64,"thumbnail":"https://cdn.glitch.com/5c795a21-9bc7-4a14-9c9d-409f90b57ca0%2Ffavicon.ico","thumbnailWidth":64,"thumbnailHeight":64,"dominantColor":null,"uuid":"y0sCEOhStQooC8kt"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,61 @@ | ||
Welcome to the Glitch BETA | ||
img-find | ||
========================= | ||
|
||
Click `Show` in the header to see your app live. Updates to your code will instantly deploy and update live. | ||
------------------------------ | ||
|
||
**Glitch** is the friendly commmunity where you'll build the app of your dreams. Glitch lets you instantly create, remix, edit, and host an app, bot or site, and you can invite collaborators or helpers to simultaneously edit code with you. | ||
### An Image Search Abstraction Layer | ||
|
||
Find out more [about Glitch](https://glitch.com/about). | ||
* [https://img-find.glitch.me/](https://img-find.glitch.me/) | ||
|
||
Use this microservice to retrieve image search results in json. The six available parameters for this API are described below. | ||
|
||
Your Project | ||
------------ | ||
### How To Use | ||
|
||
On the front-end, | ||
- edit `public/client.js`, `public/style.css` and `views/index.html` | ||
- drag in `assets`, like images or music, to add them to your project | ||
Append your search query parameters to the end of the API search endpoint `https://img-find.glitch.me/search?` with all parameters separated by the symbol `&`. | ||
|
||
On the back-end, | ||
- your app starts at `server.js` | ||
- add frameworks and packages in `package.json` | ||
- safely store app secrets in `.env` (nobody can see this but you and people you invite) | ||
**Example Query** | ||
|
||
`https://img-find.glitch.me/search?offset=2&q=fancy penguins&size=large` | ||
|
||
Made by [Fog Creek](https://fogcreek.com/) | ||
------------------- | ||
**Example Output** | ||
|
||
``` | ||
[ | ||
{ | ||
"snippet": "Penguin cartoon β penguins at a fancy dress ...", | ||
"url": "http://www.chrismadden.co.uk/images/cartoons ...", | ||
"thumbnail": "https://encrypted-tbn0.gstatic.com/ ...", | ||
"context": "http://www.chrismadden.co.uk/cartoon ..." | ||
}, | ||
{ | ||
"snippet": "Kracker's Art Suite", | ||
"url": "http://thestuffinthemargin.files.wordpress ...", | ||
"thumbnail": "https://encrypted-tbn0.gstatic.com/ ...", | ||
"context": "http://krackerartsuite.blogspot.com/" | ||
} | ||
] | ||
``` | ||
|
||
### Parameters | ||
|
||
|Parameter |Description | | ||
|-------------|------------------------| | ||
|q |Query (string) | | ||
|num |Number of search results to return per page. Default: 10 Max: 10 (integer)| | ||
|offset |Page of search results to return. Default: 1 Max: 90 (integer)| | ||
|size|Img size: icon, small, medium, large, xlarge, xxlarge, or huge. (string)| | ||
|type|Img type. Including: bmp, gif, png, jpg, svg, pdf, ... (string)| | ||
|rights|Licensing values include: cc_publicdomain, cc_attribute, cc_sharealike, cc_noncommercial, cc_nonderived & combinations of these. (string)| | ||
|
||
### API Explorer Form | ||
|
||
\ γoγ)γ | ||
You can use the form on the [API landing page](https://img-find.glitch.me/) to explore the API. Searches will return the query url and example output printed in formatted json. | ||
|
||
**Project Landing Page** | ||
|
||
* [https://img-find.glitch.me/](https://img-find.glitch.me/) | ||
|
||
------------------------- | ||
|
||
Made by [IMBurbank](https://fogcreek.com/) | ||
------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
{ | ||
"//1": "describes your app and its dependencies", | ||
"//2": "https://docs.npmjs.com/files/package.json", | ||
"//3": "updating this file will download and update your packages", | ||
|
||
"name": "my-glitch-app", | ||
"version": "0.0.1", | ||
"description": "What am I about?", | ||
"name": "img-find", | ||
"version": "1.0.0", | ||
"description": "An Image Search Abstraction Layer", | ||
"main": "server.js", | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.15.3" | ||
"express": "^4.15.3", | ||
"axios": "^0.16.2", | ||
"mongodb": "^2.2.30" | ||
}, | ||
"engines": { | ||
"node": "8.x" | ||
"node": "8.1.x" | ||
}, | ||
"repository": { | ||
"url": "https://glitch.com/edit/#!/welcome-project" | ||
"url": "https://github.com/IMBurbank/img-find" | ||
}, | ||
"license": "MIT", | ||
"keywords": [ | ||
"node", | ||
"glitch", | ||
"express" | ||
"express", | ||
"mongodb", | ||
"es8", | ||
"image-search-abstraction", | ||
"glitch", | ||
"freecodecamp" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,38 @@ | ||
// client-side js | ||
// run by the browser each time your view template is loaded | ||
// run by the browser each time view template is loaded | ||
|
||
// by default, you've got jQuery, | ||
// add other scripts at the bottom of index.html | ||
|
||
$(function() { | ||
console.log('hello world :o'); | ||
(function() { | ||
var baseUrl = 'https://img-find.glitch.me/search?', | ||
output = document.getElementById('output'), | ||
request = document.getElementById('request'), | ||
topInput = document.getElementById('input-q'), | ||
queryKeyMap; | ||
|
||
$.get('/dreams', function(dreams) { | ||
dreams.forEach(function(dream) { | ||
$('<li></li>').text(dream).appendTo('ul#dreams'); | ||
}); | ||
fetch('/queryKeyMap').then( function(response) { | ||
return response.json(); | ||
}).then( function(json) { | ||
queryKeyMap = json; | ||
}); | ||
|
||
$('form').submit(function(event) { | ||
|
||
topInput.focus(); | ||
|
||
document.getElementById('search-form').onsubmit = function(event) { | ||
event.preventDefault(); | ||
var dream = $('input').val(); | ||
$.post('/dreams?' + $.param({dream: dream}), function() { | ||
$('<li></li>').text(dream).appendTo('ul#dreams'); | ||
$('input').val(''); | ||
$('input').focus(); | ||
|
||
var query = Object.keys(queryKeyMap).reduce( function(queryStr, key) { | ||
return event.target['input-' + key].value ? | ||
queryStr + key + '=' + event.target['input-' + key].value + '&' : | ||
queryStr; | ||
}, ''); | ||
|
||
fetch('/search?' + query).then( function(response) { | ||
return response.json(); | ||
}).then( function(json) { | ||
request.innerText = baseUrl + query; | ||
output.innerHTML = '<pre>' + JSON.stringify(json, null, ' ') + '</pre>'; | ||
topInput.value = ''; | ||
topInput.focus(); | ||
}); | ||
}); | ||
|
||
}); | ||
} | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.