sfc-utils 1.3.25 → 1.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +4 -2
  2. package/accountswap.js +3 -2
  3. package/copy/c2p_sheet.js +7 -7
  4. package/css/nav2.less +1 -1
  5. package/example/.prettierrc +5 -0
  6. package/example/README.md +8 -0
  7. package/example/gatsby-config.js +131 -0
  8. package/example/gatsby-node.js +45 -0
  9. package/example/package-lock.json +13418 -0
  10. package/example/package.json +71 -0
  11. package/example/project-config.json +42 -0
  12. package/example/src/components/layout.js +236 -0
  13. package/example/src/components/sfc/ad.js +47 -0
  14. package/example/src/components/sfc/ai2html/ai2html_template.ai +1369 -4
  15. package/example/src/components/sfc/button.js +40 -0
  16. package/example/src/components/sfc/byline.js +42 -0
  17. package/example/src/components/sfc/component-helpers/customhooks.js +17 -0
  18. package/example/src/components/sfc/component-helpers/datehelpers.js +55 -0
  19. package/example/src/components/sfc/component-helpers/newsletterhelpers.js +89 -0
  20. package/example/src/components/sfc/component-helpers/requesthelpers.js +7 -0
  21. package/example/src/components/sfc/component-helpers/scrolldownhelpers.js +11 -0
  22. package/example/src/components/sfc/component-helpers/utilfunctions.js +68 -0
  23. package/example/src/components/sfc/creditline.js +35 -0
  24. package/example/src/components/sfc/credits.js +17 -0
  25. package/example/src/components/sfc/creditssection.js +47 -0
  26. package/example/src/components/sfc/dropcap.js +15 -0
  27. package/example/src/components/sfc/footer.js +36 -0
  28. package/example/src/components/sfc/geocoder.js +148 -0
  29. package/example/src/components/sfc/misccredit.js +17 -0
  30. package/example/src/components/sfc/navtop.js +121 -0
  31. package/example/src/components/sfc/newsletter.js +157 -0
  32. package/example/src/components/sfc/relatedlink.js +23 -0
  33. package/example/src/components/sfc/relatedrow.js +23 -0
  34. package/example/src/components/sfc/relatedsection.js +27 -0
  35. package/example/src/components/sfc/safelink.js +86 -0
  36. package/example/src/components/sfc/scrolldown.js +22 -0
  37. package/example/src/components/sfc/sharebuttons.js +93 -0
  38. package/example/src/components/sfc/topper.js +88 -0
  39. package/example/src/components/sfc/video.js +74 -0
  40. package/example/src/components/sfc/wcmimage.js +131 -0
  41. package/example/src/data/sfc/images/react.gif +0 -0
  42. package/example/src/data/sfc/related_links.json +17 -0
  43. package/example/src/html.js +41 -0
  44. package/example/src/pages/index.js +143 -0
  45. package/example/src/styles/defaults.less +99 -0
  46. package/example/src/styles/footer.less +345 -0
  47. package/example/src/styles/modules/ad.module.less +21 -0
  48. package/example/src/styles/modules/ai2html.module.less +19 -0
  49. package/example/src/styles/modules/button.module.less +94 -0
  50. package/example/src/styles/modules/byline.module.less +11 -0
  51. package/example/src/styles/modules/creditline.module.less +12 -0
  52. package/example/src/styles/modules/credits.module.less +7 -0
  53. package/example/src/styles/modules/creditssection.module.less +17 -0
  54. package/example/src/styles/modules/dropcap.module.less +18 -0
  55. package/example/src/styles/modules/geocoder.module.less +79 -0
  56. package/example/src/styles/modules/newsletter.module.less +147 -0
  57. package/example/src/styles/modules/relatedlink.module.less +28 -0
  58. package/example/src/styles/modules/relatedrow.module.less +8 -0
  59. package/example/src/styles/modules/relatedsection.module.less +19 -0
  60. package/example/src/styles/modules/scrolldown.module.less +31 -0
  61. package/example/src/styles/modules/share.module.less +22 -0
  62. package/example/src/styles/modules/topper.module.less +63 -0
  63. package/example/src/styles/modules/video.module.less +27 -0
  64. package/example/src/styles/modules/wcmimage.module.less +20 -0
  65. package/example/src/styles/nav.less +187 -0
  66. package/example/src/styles/project.less +1 -0
  67. package/example/src/styles/reset.css +95 -0
  68. package/example/src/styles/seed.less +5 -0
  69. package/example/src/styles/typography.css +168 -0
  70. package/example/src/styles/values.less +74 -0
  71. package/example/static/manifest.webmanifest +1 -0
  72. package/example/tasks/create-c2p-sheet.js +6 -0
  73. package/example/tasks/deploy-addon.py +14 -0
  74. package/example/tasks/google-docs.js +16 -0
  75. package/example/tasks/google-sheets.js +17 -0
  76. package/example/tasks/node-helpers.js +81 -0
  77. package/example/tasks/post-build.sh +7 -0
  78. package/example/tasks/pre-build.sh +18 -0
  79. package/example/tempsettings.js +28 -0
  80. package/package.json +1 -1
  81. package/settings.js +1 -1
package/README.md CHANGED
@@ -35,16 +35,18 @@ You can still install what's on master by running `npm i git+https://github.com/
35
35
 
36
36
  ## Updating utils
37
37
 
38
- Ask Evan for the npm credentials for publishing. Once you have them, these are the steps:
38
+ Create an npm account and ask Evan to add you as a maintainer. You MUST enable two-factor on your account to push updates. Once you are all set, these are the steps:
39
39
 
40
40
  1. Make sure you've incremented the version number in package.json.
41
41
 
42
42
  1. Update the master branch with changes you want to push.
43
43
 
44
- 1. Log in to npm via the terminal with `npm login`.
44
+ 1. Log in to npm via the terminal with `npm login` (this only needs to be done once).
45
45
 
46
46
  1. Run `npm publish`.
47
47
 
48
+ If you want to publish a version of utils that should only be `beta`, not the default install version, then run `npm publish --tag beta` instead. Then when installing, you must target the new version directly: `npm i sfc-utils@1.3.24`
49
+
48
50
 
49
51
  ## Import the functions
50
52
 
package/accountswap.js CHANGED
@@ -12,9 +12,10 @@ const pollForAccount = function(i){
12
12
  if (window && window.treg && window.treg.identity && window.treg.identity.id){
13
13
  // We got a valid entitlement! Let's see if the button exists and swap our new one in
14
14
  const subButton = document.querySelector('#nav2-sub-box')
15
+ const subButtonText = subButton.querySelector('div')
15
16
  if (subButton){
16
17
  subButton.setAttribute("href", accountURL)
17
- subButton.innerText = "Account"
18
+ subButtonText.innerText = "Account"
18
19
  }
19
20
  } else {
20
21
  if (i > 10){
@@ -26,4 +27,4 @@ const pollForAccount = function(i){
26
27
  }
27
28
  }
28
29
 
29
- module.exports = { pollForAccount }
30
+ module.exports = { pollForAccount }
package/copy/c2p_sheet.js CHANGED
@@ -17,24 +17,24 @@ var path = require("path");
17
17
  // let configData = JSON.parse(config)
18
18
 
19
19
  let googleAuth = (configData) => {
20
- var auth = null;
21
- authObj
22
- .authenticate({ fallback: false })
23
- .then((resp) => {
20
+ return new Promise(resolve => {
21
+ var auth = null;
22
+ authObj.authenticate({ fallback: false }).then((resp) => {
24
23
  auth = resp;
25
- createSheet(auth, false, configData).catch(() => {
24
+ createSheet(auth, false, configData).then(() => {resolve()}).catch(() => {
26
25
  // If the first attempt failed, then make another req using the fallback
27
26
  authObj.authenticate({ fallback: true }).then((resp) => {
28
27
  auth = resp;
29
- createSheet(auth, true, configData);
28
+ createSheet(auth, true, configData).then(() => {resolve()});
30
29
  });
31
30
  });
32
31
  })
33
32
  .catch(() => {
34
33
  // Failure if we fall back but there's no token
35
34
  auth = authObj.task();
36
- createSheet(auth, true, configData);
35
+ createSheet(auth, true, configData).then(() => {resolve()});
37
36
  });
37
+ })
38
38
  };
39
39
 
40
40
  let createSheet = (auth, fallback, configData) => {
package/css/nav2.less CHANGED
@@ -70,7 +70,7 @@
70
70
  }
71
71
  #nav2-sub-box {
72
72
  border: none;
73
- color:white;
73
+ color: white;
74
74
  text-transform: none;
75
75
  text-decoration: underline white;
76
76
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "semi": false,
3
+ "singleQuote": true,
4
+ "trailingComma": "es5"
5
+ }
@@ -0,0 +1,8 @@
1
+ # {%= app_slug %}
2
+
3
+ {%= github_desc %}
4
+
5
+ View the live project: [{%= project_url %}]({%= project_url %})
6
+
7
+ This project was built with the SFC Newsapp template. For instructions on how to use this template, refer to [the template README](https://github.com/sfchronicle/gatsby-newsapp))
8
+
@@ -0,0 +1,131 @@
1
+ // Add SFC utils
2
+ const { getBrands, getNav, getFooter } = require('../index')
3
+ const { getSettings } = require('./tempsettings')
4
+ const { DateTime } = require('luxon');
5
+
6
+ let settings = getSettings()
7
+
8
+ let marketKeyArray = [
9
+ {"markets": ["SFC"], "zone": "America/Los_Angeles"},
10
+ {"markets": ["Houston","SanAntonio","Texcom"], "zone": "America/Chicago"},
11
+ {"markets": ["Albany","CT","Midcom"], "zone": "America/New_York"},
12
+ ]
13
+
14
+ let currentZone
15
+ // Find the current market in the array
16
+ for (let region in marketKeyArray){
17
+ let thisRegion = marketKeyArray[region]
18
+ if (thisRegion.markets.includes(settings.PROJECT.MARKET_KEY)){
19
+ currentZone = thisRegion.zone
20
+ }
21
+ }
22
+ // If we don't have a match, that means we have an invalid market key
23
+ if (!currentZone){
24
+ console.error("Invalid or undefined MARKET_KEY! See the _key_explainer in project-config to see valid values.")
25
+ process.exit(1)
26
+ }
27
+
28
+ // Create computer pub and mod dates
29
+ const dt = DateTime.fromFormat(
30
+ settings.PROJECT.DATE,
31
+ 'MMMM d, y h:mm a',
32
+ {zone: currentZone}
33
+ )
34
+ // Convert date to computer-readable time
35
+ const computerPubDate = dt.toISO()
36
+ settings.PROJECT.ISO_PUBDATE = computerPubDate
37
+
38
+ // If MOD_DATE does not exist, set var to pubdate
39
+ let computerModDate = ""
40
+ if (typeof settings.PROJECT.MOD_DATE !== 'undefined' && settings.PROJECT.MOD_DATE) {
41
+ const dt2 = DateTime.fromFormat(
42
+ settings.PROJECT.MOD_DATE,
43
+ 'MMMM d, y h:mm a',
44
+ {zone: currentZone}
45
+ )
46
+ computerModDate = dt2.toISO()
47
+ } else {
48
+ // Fallback to creation date
49
+ computerModDate = computerPubDate
50
+ }
51
+ settings.PROJECT.ISO_MODDATE = computerModDate
52
+
53
+ //Set get the current env var
54
+ const currentEnv = process.env.GATSBY_DEPLOY_ENV
55
+ console.log('Current environment: ' + currentEnv)
56
+
57
+ // Handle test prefix
58
+ // TODO: Once we embrace the new URL, we can delete this check and hardcode /projects
59
+ let projectsPrefix = ""
60
+ if (settings.PROJECT.SUBFOLDER.toString().indexOf("projects/") === 0){
61
+ projectsPrefix = "/projects"
62
+ }
63
+ // Set the path prefix for the given deploy (ignored for dev)
64
+ let pathPrefix = '/projects/test-proj/' + settings.PROJECT.SLUG
65
+ if (currentEnv === 'development') {
66
+ pathPrefix = '/'
67
+ }
68
+ if (currentEnv === 'app') {
69
+ pathPrefix = projectsPrefix + '/app/' + settings.PROJECT.SLUG
70
+ }
71
+ if (currentEnv === 'production') {
72
+ pathPrefix =
73
+ '/' +
74
+ settings.PROJECT.SUBFOLDER +
75
+ settings.PROJECT.OPT_SLASH +
76
+ settings.PROJECT.SLUG
77
+ }
78
+
79
+ let plugins = [
80
+ 'gatsby-plugin-react-helmet',
81
+ 'gatsby-transformer-json',
82
+ {
83
+ resolve: 'gatsby-plugin-less',
84
+ options: {
85
+ lessOptions: {
86
+ modifyVars: getBrands(settings.PROJECT.MARKET_KEY).styles,
87
+ },
88
+ },
89
+ },
90
+ {
91
+ resolve: 'gatsby-plugin-html-attributes',
92
+ options: {
93
+ lang: 'en',
94
+ },
95
+ },
96
+ {
97
+ resolve: `gatsby-source-filesystem`,
98
+ options: {
99
+ name: `projectData`,
100
+ path: `${__dirname}/src/data/`,
101
+ },
102
+ },
103
+ {
104
+ resolve: 'gatsby-plugin-webpack-bundle-analyser-v2',
105
+ options: {
106
+ production: true,
107
+ disable: !process.env.ANALYZE_BUNDLE_SIZE,
108
+ generateStatsFile: true,
109
+ analyzerMode: 'static',
110
+ },
111
+ },
112
+ // this (optional) plugin enables Progressive Web App + Offline functionality
113
+ // To learn more, visit: https://gatsby.app/offline
114
+ // 'gatsby-plugin-offline',
115
+ ]
116
+
117
+ // Enable preact for the prod build
118
+ if (currentEnv !== "development"){
119
+ plugins.push("gatsby-plugin-preact")
120
+ }
121
+
122
+ // TK builds get weird redirect loops with htaccess plugin, so don't use it
123
+ if (settings.PROJECT.MARKET_KEY !== "TK"){
124
+ plugins.push("gatsby-plugin-htaccess")
125
+ }
126
+
127
+ module.exports = {
128
+ siteMetadata: settings,
129
+ pathPrefix: pathPrefix,
130
+ plugins: plugins
131
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Implement Gatsby's Node APIs in this file.
3
+ *
4
+ * See: https://www.gatsbyjs.org/docs/node-apis/
5
+ */
6
+
7
+ var {requestImage} = require("./tasks/node-helpers");
8
+
9
+ // Import all the WCM photos you'd like to use in this project
10
+ // NOTE: Leave this as an empty array if you aren't importing any WCM photos, but you won't be able to use the WCMImage component
11
+ const wcmPhotos = [20374215]
12
+
13
+ // Create nodes so GraphQL can access
14
+ exports.sourceNodes = async ({
15
+ actions,
16
+ createNodeId,
17
+ createContentDigest,
18
+ }) => {
19
+ const { createNode } = actions
20
+
21
+ // Request and push photo data into an array
22
+ const photoData = [];
23
+ wcmPhotos.forEach((url) => {
24
+ photoData.push(requestImage(url))
25
+ })
26
+
27
+ // Take the ratios/ids turn them into graphql nodes
28
+ await Promise.all(photoData).then((values) => {
29
+ values.forEach((photo) => {
30
+ const type = "wcmPhotos";
31
+ createNode({
32
+ photo,
33
+ id: createNodeId(`${type}${photo.wcmid}`),
34
+ parent: null,
35
+ children: [],
36
+ internal: {
37
+ contentDigest: createContentDigest(photo),
38
+ type,
39
+ },
40
+ })
41
+ })
42
+ return
43
+ })
44
+ return
45
+ }