Compare commits

...

3 Commits

Author SHA1 Message Date
73ae6d89f8 Update home screenshot 2018-03-13 19:10:51 +01:00
171bf33fff Add screenshots 2018-03-13 19:09:16 +01:00
680f00c188 Factor API calls 2018-03-13 19:02:10 +01:00
6 changed files with 19 additions and 14 deletions

View File

@ -5,6 +5,10 @@ Cuizin is a tool wrapping around [Web Outside Of Browsers](http://weboob.org/)
to help you sort and organize recipes you find online. You can also manually
add new recipes.
![Homepage](screenshots/home.png)
More screenshots are available in the [`screenshots` folder](screenshots/).
## Installation

View File

@ -1,6 +1,14 @@
import * as constants from '@/constants';
function fetchAPI(endpoint, params = {}) {
return fetch(
`${constants.API_URL}${endpoint}`,
Object.assign({}, { credentials: 'same-origin' }, params),
);
}
function loadJSON(response) {
return response.json();
}
@ -29,59 +37,52 @@ function _postProcessRecipes(response) {
export function loadRecipes() {
return fetch(`${constants.API_URL}api/v1/recipes`, { credentials: 'same-origin' })
return fetchAPI('api/v1/recipes')
.then(_postProcessRecipes);
}
export function loadRecipe(id) {
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, { credentials: 'same-origin' })
return fetchAPI(`api/v1/recipe/${id}`)
.then(_postProcessRecipes);
}
export function refetchRecipe(id) {
return fetch(
`${constants.API_URL}api/v1/recipe/${id}/refetch`,
{ credentials: 'same-origin' },
)
return fetchAPI(`api/v1/recipe/${id}/refetch`)
.then(_postProcessRecipes);
}
export function postRecipeByUrl(recipe) {
return fetch(`${constants.API_URL}api/v1/recipes/by_url`, {
return fetchAPI('api/v1/recipes/by_url', {
method: 'POST',
body: JSON.stringify(recipe),
credentials: 'same-origin',
})
.then(_postProcessRecipes);
}
export function postRecipeManually(recipe) {
return fetch(`${constants.API_URL}api/v1/recipes/manually`, {
return fetchAPI('api/v1/recipes/manually', {
method: 'POST',
body: JSON.stringify(recipe),
credentials: 'same-origin',
})
.then(_postProcessRecipes);
}
export function editRecipe(id, recipe) {
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, {
return fetchAPI(`api/v1/recipe/${id}`, {
method: 'POST',
body: JSON.stringify(recipe),
credentials: 'same-origin',
})
.then(_postProcessRecipes);
}
export function deleteRecipe(id) {
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, {
return fetchAPI(`api/v1/recipe/${id}`, {
method: 'DELETE',
credentials: 'same-origin',
});
}

BIN
screenshots/add_recipe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
screenshots/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

BIN
screenshots/recipe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 KiB