Skip to content

Commit

Permalink
#692 [WIP] Host domains and variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldrian committed Aug 10, 2018
1 parent ed1c1da commit cfcb0f0
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 11 deletions.
72 changes: 69 additions & 3 deletions app/scripts/actions/export.actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ export default {
);

if (hosting) {
const patch = prototypoStore
.set('hostingBuffer', buffer)
.commit();
const patch = prototypoStore.set('hostingBuffer', buffer).commit();

localServer.dispatchUpdate('/prototypoStore', patch);
}
Expand Down Expand Up @@ -390,6 +388,74 @@ export default {
localClient.dispatchAction('/end-export-otf');
});
},
'/host-from-library': async ({
familyNames,
variantNames,
valueArray,
metadataArray,
templateArray,
glyphsArray,
}) => {
const promiseArray = [];
const fontMediatorInstance = FontMediator.instance();

variantNames.forEach((variantName, index) => {
console.log(`exporting ${variantName} number ${index}`);
promiseArray.push(
new Promise((resolve, reject) => {
const subset = Object.keys(glyphsArray[index]).filter(
key => glyphsArray[index][key][0].unicode !== undefined,
);
const family = familyNames[index].replace(/\s/g, '-');
const style = variantName
? variantName.replace(/\s/g, '-')
: 'regular';
const name = {
family,
style: `${style.toLowerCase()}`,
};

console.log('getting font file');
fontMediatorInstance
.getFontFile(
name,
templateArray[index],
{...valueArray[index]},
subset,
undefined,
undefined,
undefined,
undefined,
metadataArray[index].weight,
metadataArray[index].width,
metadataArray[index].italic,
)
.then((buffer) => {
console.log(`${variantName} Buffer recieved!`);
resolve(buffer);
})
.catch((e) => {
console.log(e);
reject(e);
});
}),
);
});

Promise.all(promiseArray)
.then((blobBuffers) => {
const patch = prototypoStore
.set('hostingBuffers', blobBuffers)
.commit();

localServer.dispatchUpdate('/prototypoStore', patch);
})
.catch((e) => {
console.log('An error occured');
console.log(e);
localClient.dispatchAction('/end-export-otf');
});
},
'/end-export-otf': () => {
console.log('Export finished');
localClient.dispatchAction('/store-value-font', {exportPlease: false});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,19 @@ const libraryUserQuery = gql`
}
template
}
hostedDomains {
id
domain
hostedVariants {
id
createdAt
origin {
id
}
url
version
}
}
}
}
`;
Expand Down
Loading

0 comments on commit cfcb0f0

Please sign in to comment.