-
Notifications
You must be signed in to change notification settings - Fork 5
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 #902 from MuckRock/898-embed-cache
- Loading branch information
Showing
13 changed files
with
100 additions
and
33 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
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
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
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
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
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
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,25 +1,22 @@ | ||
/** | ||
* Data loading for upload | ||
*/ | ||
|
||
import { redirect } from "@sveltejs/kit"; | ||
import * as projectsApi from "$lib/api/projects"; | ||
|
||
export async function load({ fetch, parent }) { | ||
const { me } = await parent(); | ||
|
||
if (me) { | ||
const projects = await projectsApi.list( | ||
{ per_page: 100, user: me.id }, | ||
fetch, | ||
); | ||
|
||
return { | ||
projects: projects.data, | ||
}; | ||
if (!me) { | ||
return redirect(302, "/home/"); | ||
} | ||
|
||
// anonymous gets empty results | ||
const projects = await projectsApi.list( | ||
{ per_page: 100, user: me.id }, | ||
fetch, | ||
); | ||
|
||
return { | ||
projects: { results: [] }, | ||
projects: projects.data, | ||
}; | ||
} |
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,18 +1,23 @@ | ||
// load data for flatpages | ||
import { error } from "@sveltejs/kit"; | ||
|
||
import { PAGE_MAX_AGE } from "@/config/config.js"; | ||
import * as flatpages from "$lib/api/flatpages"; | ||
|
||
export async function load({ fetch, params }) { | ||
export async function load({ fetch, params, setHeaders }) { | ||
const { data, error: err } = await flatpages.get(params.path, fetch); | ||
|
||
if (err) { | ||
return error(err.status, { message: err.message }); | ||
} | ||
|
||
if (!data) { | ||
return error(404, "Page not found"); | ||
} | ||
|
||
if (err) { | ||
return error(err.status, { message: err.message }); | ||
} | ||
setHeaders({ | ||
"cache-control": `public, max-age=${PAGE_MAX_AGE}`, | ||
}); | ||
|
||
return data; | ||
} |
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
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
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
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
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