sfc-utils 1.3.24 → 1.3.27

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 (80) hide show
  1. package/accountswap.js +3 -2
  2. package/brands.js +1 -1
  3. package/css/nav2.less +2 -1
  4. package/example/.prettierrc +5 -0
  5. package/example/README.md +8 -0
  6. package/example/gatsby-config.js +131 -0
  7. package/example/gatsby-node.js +45 -0
  8. package/example/package-lock.json +13418 -0
  9. package/example/package.json +71 -0
  10. package/example/project-config.json +42 -0
  11. package/example/src/components/layout.js +236 -0
  12. package/example/src/components/sfc/ad.js +47 -0
  13. package/example/src/components/sfc/ai2html/ai2html_template.ai +1369 -4
  14. package/example/src/components/sfc/button.js +40 -0
  15. package/example/src/components/sfc/byline.js +42 -0
  16. package/example/src/components/sfc/component-helpers/customhooks.js +17 -0
  17. package/example/src/components/sfc/component-helpers/datehelpers.js +55 -0
  18. package/example/src/components/sfc/component-helpers/newsletterhelpers.js +89 -0
  19. package/example/src/components/sfc/component-helpers/requesthelpers.js +7 -0
  20. package/example/src/components/sfc/component-helpers/scrolldownhelpers.js +11 -0
  21. package/example/src/components/sfc/component-helpers/utilfunctions.js +68 -0
  22. package/example/src/components/sfc/creditline.js +35 -0
  23. package/example/src/components/sfc/credits.js +17 -0
  24. package/example/src/components/sfc/creditssection.js +47 -0
  25. package/example/src/components/sfc/dropcap.js +15 -0
  26. package/example/src/components/sfc/footer.js +36 -0
  27. package/example/src/components/sfc/geocoder.js +148 -0
  28. package/example/src/components/sfc/misccredit.js +17 -0
  29. package/example/src/components/sfc/navtop.js +121 -0
  30. package/example/src/components/sfc/newsletter.js +157 -0
  31. package/example/src/components/sfc/relatedlink.js +23 -0
  32. package/example/src/components/sfc/relatedrow.js +23 -0
  33. package/example/src/components/sfc/relatedsection.js +27 -0
  34. package/example/src/components/sfc/safelink.js +86 -0
  35. package/example/src/components/sfc/scrolldown.js +22 -0
  36. package/example/src/components/sfc/sharebuttons.js +93 -0
  37. package/example/src/components/sfc/topper.js +88 -0
  38. package/example/src/components/sfc/video.js +74 -0
  39. package/example/src/components/sfc/wcmimage.js +131 -0
  40. package/example/src/data/sfc/images/react.gif +0 -0
  41. package/example/src/data/sfc/related_links.json +17 -0
  42. package/example/src/html.js +41 -0
  43. package/example/src/pages/index.js +143 -0
  44. package/example/src/styles/defaults.less +99 -0
  45. package/example/src/styles/footer.less +345 -0
  46. package/example/src/styles/modules/ad.module.less +21 -0
  47. package/example/src/styles/modules/ai2html.module.less +19 -0
  48. package/example/src/styles/modules/button.module.less +94 -0
  49. package/example/src/styles/modules/byline.module.less +11 -0
  50. package/example/src/styles/modules/creditline.module.less +12 -0
  51. package/example/src/styles/modules/credits.module.less +7 -0
  52. package/example/src/styles/modules/creditssection.module.less +17 -0
  53. package/example/src/styles/modules/dropcap.module.less +18 -0
  54. package/example/src/styles/modules/geocoder.module.less +79 -0
  55. package/example/src/styles/modules/newsletter.module.less +147 -0
  56. package/example/src/styles/modules/relatedlink.module.less +28 -0
  57. package/example/src/styles/modules/relatedrow.module.less +8 -0
  58. package/example/src/styles/modules/relatedsection.module.less +19 -0
  59. package/example/src/styles/modules/scrolldown.module.less +31 -0
  60. package/example/src/styles/modules/share.module.less +22 -0
  61. package/example/src/styles/modules/topper.module.less +63 -0
  62. package/example/src/styles/modules/video.module.less +27 -0
  63. package/example/src/styles/modules/wcmimage.module.less +20 -0
  64. package/example/src/styles/nav.less +187 -0
  65. package/example/src/styles/project.less +1 -0
  66. package/example/src/styles/reset.css +95 -0
  67. package/example/src/styles/seed.less +5 -0
  68. package/example/src/styles/typography.css +168 -0
  69. package/example/src/styles/values.less +74 -0
  70. package/example/static/manifest.webmanifest +1 -0
  71. package/example/tasks/create-c2p-sheet.js +6 -0
  72. package/example/tasks/deploy-addon.py +14 -0
  73. package/example/tasks/google-docs.js +16 -0
  74. package/example/tasks/google-sheets.js +17 -0
  75. package/example/tasks/node-helpers.js +81 -0
  76. package/example/tasks/post-build.sh +7 -0
  77. package/example/tasks/pre-build.sh +18 -0
  78. package/example/tempsettings.js +28 -0
  79. package/package.json +1 -1
  80. package/settings.js +1 -1
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/brands.js CHANGED
@@ -17,7 +17,7 @@ let getBrands = function(market){
17
17
  "@sans-bold": '"Source Sans Pro Bold", Helvetica, sans-serif',
18
18
 
19
19
  // Icons
20
- "@sub-icon": `url('data:image/svg+xml, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor"><path d="M160 416H96c-17.67 0-32-14.33-32-32V128c0-17.67 14.33-32 32-32h64c17.67 0 32-14.33 32-32S177.7 32 160 32H96C42.98 32 0 74.98 0 128v256c0 53.02 42.98 96 96 96h64c17.67 0 32-14.33 32-32S177.7 416 160 416zM502.6 233.4l-128-128c-12.51-12.51-32.76-12.49-45.25 0c-12.5 12.5-12.5 32.75 0 45.25L402.8 224H192C174.3 224 160 238.3 160 256s14.31 32 32 32h210.8l-73.38 73.38c-12.5 12.5-12.5 32.75 0 45.25s32.75 12.5 45.25 0l128-128C515.1 266.1 515.1 245.9 502.6 233.4z"/></svg>')`,
20
+ "@sub-icon": `url('data:image/svg+xml, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="white"><path d="M160 416H96c-17.67 0-32-14.33-32-32V128c0-17.67 14.33-32 32-32h64c17.67 0 32-14.33 32-32S177.7 32 160 32H96C42.98 32 0 74.98 0 128v256c0 53.02 42.98 96 96 96h64c17.67 0 32-14.33 32-32S177.7 416 160 416zM502.6 233.4l-128-128c-12.51-12.51-32.76-12.49-45.25 0c-12.5 12.5-12.5 32.75 0 45.25L402.8 224H192C174.3 224 160 238.3 160 256s14.31 32 32 32h210.8l-73.38 73.38c-12.5 12.5-12.5 32.75 0 45.25s32.75 12.5 45.25 0l128-128C515.1 266.1 515.1 245.9 502.6 233.4z"/></svg>')`,
21
21
  },
22
22
  attributes: {
23
23
  "subscribeLink": "https://www.hearst.com/newspapers?projects=true"
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
  }
@@ -100,6 +100,7 @@
100
100
  &::after {
101
101
  content: " ";
102
102
  background-image: @sub-icon;
103
+ filter: invert(1);
103
104
  }
104
105
  }
105
106
  }
@@ -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
+ }