Skip to content

Commit

Permalink
Merge branch 'master' into update-title-case
Browse files Browse the repository at this point in the history
  • Loading branch information
ziel-ar committed Oct 14, 2019
2 parents b891d9c + 84fa85d commit 7771886
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 38 deletions.
1 change: 1 addition & 0 deletions docs/contributing/setting-up-your-local-dev-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Yarn is a package manager for your code, similar to [NPM](https://www.npmjs.com/

## Gatsby repo install instructions

- Ensure you have the latest version of Node installed (>= 10.16.0). `node --version`
- [Install](https://yarnpkg.com/en/docs/install) the Yarn package manager.
- Ensure you have the latest version of Yarn installed (>= 1.0.2). `yarn --version`
- Fork the [official repository](https://github.com/gatsbyjs/gatsby).
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/schema-customization.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Schema Customization
title: Customizing the GraphQL Schema
---

One of Gatsby's main strengths is the ability to query data from a variety of
Expand Down
47 changes: 46 additions & 1 deletion docs/sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5568,15 +5568,20 @@
main_url: https://www.element84.com
url: https://www.element84.com
description: >
A software development firm that designs and builds ambitious software products engineered for high scalability.
Element 84 is software engineering and design firm that helps companies and government agencies solve problems using remote sensing, life sciences, and transportation data in the cloud.
categories:
- Agency
- Blog
- Business
- Consulting
- Data
- Design
- Government
- Portfolio
- Programming
- Science
- Technology
- User Experience
- Web Development
- title: Measures for Justice
main_url: https://www.measuresforjustice.org
Expand Down Expand Up @@ -7696,6 +7701,35 @@
built_by: Phil Tietjen
built_by_url: "https://github.com/Phizzard"
featured: false
- title: Divyanshu Maithani
main_url: https://divyanshu013.dev
url: https://divyanshu013.dev
source_url: https://github.com/divyanshu013/blog
description: >
Personal blog of Divyanshu Maithani. Life, music, code and things in between...
categories:
- Blog
- JavaScript
- Open Source
- Music
- Programming
- Technology
- Web Development
built_by: Divyanshu Maithani
built_by_url: https://twitter.com/divyanshu013
- title: TFE Energy
main_url: https://tfe.energy
url: https://tfe.energy
source_url: https://gitlab.com/marcfehrmedia/2019-07-03-tfe-energy
description: >
TFE Energy believes in the future. Their new website is programmed with Gatsby, Scrollmagic, Contentful, Cloudify.
categories:
- Technology
- Consulting
- Video
- Business
built_by: Marc Fehr
built_by_url: https:/www.marcfehr.media
- title: AtomBuild
url: https://atombuild.github.io/
main_url: https://atombuild.github.io/
Expand Down Expand Up @@ -7750,3 +7784,14 @@
built_by: Kframe Interactive SA
built_by_url: https://kframeinteractive.com/
featured: false
- title: Arturo Alviar's Portfolio
main_url: "https://arturoalviar.com"
url: "https://arturoalviar.com"
source_url: "https://github.com/arturoalviar/portfolio"
categories:
- Portfolio
- Open Source
- Web Development
built_by: Arturo Alviar
built_by_url: "https://github.com/arturoalviar"
featured: false
11 changes: 11 additions & 0 deletions docs/starters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4061,3 +4061,14 @@
- Google Analytics
- Simple design
- Markdown support
- url: https://gatsby-starter-material-album.netlify.com
repo: https://github.com/JoeTrubenstein/gatsby-starter-material-album
description: A simple portfolio starter based on the Material UI Album Layout
tags:
- Gallery
- Portfolio
- Styling:Material
features:
- Pagination
- Material UI
- Exif Data Parsing
2 changes: 1 addition & 1 deletion docs/tutorial/gatsby-image-tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ Now for errors to watch out for. If you change your image processing from `fixed

![In image cache error message.](./ErrorMessage.png)

Despite its appearance, solving this doesn't actually require flushing any kind of cache. In reality, it has to do with incompatible references. You likely triggered it because you changed the query to process the image as `fluid` but the JSX key was still set to `fixed`, or visa versa.
Despite its appearance, solving this doesn't actually require flushing any kind of cache. In reality, it has to do with incompatible references. You likely triggered it because you changed the query to process the image as `fluid` but the JSX key was still set to `fixed`, or vice versa.

## The end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`setJobToProcess allows brackets in paths 1`] = `
Object {
"1234/file%2Ejpg": Object {
"myoutputpath/1234/file[new]%2Ejpg": Object {
"deferred": Object {
"promise": Promise {},
"reject": [Function],
"resolve": [Function],
},
"job": Object {
"args": Object {},
"contentDigest": "8675309jenny",
"inputPath": "1234/file.jpg",
"outputPath": "myoutputpath/1234/file[new].jpg",
},
},
},
}
`;
20 changes: 20 additions & 0 deletions packages/gatsby-plugin-sharp/src/__tests__/scheduler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { setJobToProcess } = require(`../scheduler`)

describe(`setJobToProcess`, () => {
it(`allows brackets in paths`, () => {
let deferred = {}
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve
deferred.reject = reject
})
const toProcess = {}
const job = {
args: {},
inputPath: `1234/file.jpg`,
contentDigest: `8675309jenny`,
outputPath: `myoutputpath/1234/file[new].jpg`,
}
setJobToProcess(toProcess, job, deferred)
expect(toProcess).toMatchSnapshot()
})
})
55 changes: 36 additions & 19 deletions packages/gatsby-plugin-sharp/src/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,66 @@ q.drain = () => {
totalJobs = 0
}

exports.scheduleJob = async (
job,
boundActionCreators,
pluginOptions,
reporter,
reportStatus = true
) => {
const inputFileKey = job.inputPath.replace(/\./g, `%2E`)
const outputFileKey = job.outputPath.replace(/\./g, `%2E`)
const jobPath = `${inputFileKey}.${outputFileKey}`
const getFileKey = filePath => filePath.replace(/\./g, `%2E`)

const setJobToProcess = (toProcess, job, deferred) => {
const inputFileKey = getFileKey(job.inputPath)
const outputFileKey = getFileKey(job.outputPath)
const jobPath = `["${inputFileKey}"].["${outputFileKey}"]`

// Check if the job has already been queued. If it has, there's nothing
// to do, return.
if (_.has(toProcess, jobPath)) {
return _.get(toProcess, `${jobPath}.deferred.promise`)
return { existingPromise: _.get(toProcess, `${jobPath}.deferred.promise`) }
}

// Check if the output file already exists so we don't redo work.
if (existsSync(job.outputPath)) {
return Promise.resolve(job)
return { existingPromise: Promise.resolve(job) }
}

let isQueued = false
if (toProcess[inputFileKey]) {
isQueued = true
}

_.set(toProcess, jobPath, {
job: job,
deferred,
})

return { isQueued }
}

const scheduleJob = async (
job,
boundActionCreators,
pluginOptions,
reporter,
reportStatus = true
) => {
// deferred naming comes from https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred
let deferred = {}
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve
deferred.reject = reject
})

const { existingPromise, isQueued } = setJobToProcess(
toProcess,
job,
deferred
)
if (existingPromise) {
return existingPromise
}

if (totalJobs === 0) {
bar = createProgress(`Generating image thumbnails`, reporter)
bar.start()
}

totalJobs += 1

_.set(toProcess, jobPath, {
job: job,
deferred,
})

if (!isQueued) {
// Create image job
const jobId = uuidv4()
Expand All @@ -80,7 +95,7 @@ exports.scheduleJob = async (
q.push(cb => {
runJobs(
jobId,
inputFileKey,
getFileKey(job.inputPath),
boundActionCreators,
pluginOptions,
reportStatus,
Expand Down Expand Up @@ -169,3 +184,5 @@ function runJobs(
})
}
}

export { scheduleJob, setJobToProcess }
36 changes: 20 additions & 16 deletions packages/gatsby-source-drupal/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,26 @@ exports.onCreateDevServer = (
type: `application/json`,
}),
async (req, res) => {
// we are missing handling of node deletion
const nodeToUpdate = JSON.parse(JSON.parse(req.body)).data

await handleWebhookUpdate(
{
nodeToUpdate,
actions,
cache,
createNodeId,
createContentDigest,
getNode,
reporter,
store,
},
pluginOptions
)
if (!_.isEmpty(req.body)) {
// we are missing handling of node deletion
const nodeToUpdate = JSON.parse(JSON.parse(req.body)).data

await handleWebhookUpdate(
{
nodeToUpdate,
actions,
cache,
createNodeId,
createContentDigest,
getNode,
reporter,
store,
},
pluginOptions
)
} else {
res.status(400).send(`Received body was empty!`)
}
}
)
}

0 comments on commit 7771886

Please sign in to comment.