Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
62609cbc
Commit
62609cbc
authored
Jul 22, 2016
by
Ray Schamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collapse by beginning all routes with a common `^`
parent
eba654c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
17 deletions
+36
-17
bin/configure-fastly.js
bin/configure-fastly.js
+5
-5
src/routes.json
src/routes.json
+31
-12
No files found.
bin/configure-fastly.js
View file @
62609cbc
...
...
@@ -18,9 +18,9 @@ var fastly = require('./lib/fastly-extended')(process.env.FASTLY_API_KEY, FASTLY
var
extraAppRoutes
=
[
// Homepage with querystring.
// TODO: Should this be added for every route?
'
^
/
\\
?
'
,
'
/
\\
?
'
,
// View html
'
^
/[^
\
/]*
\
.html$
'
'
/[^
\
/]*
\
.html$
'
];
/*
...
...
@@ -35,7 +35,7 @@ var getStaticPaths = function (pathToStatic) {
}).
map
(
function
(
pathName
)
{
// Reduce absolute path to relative paths like '/js'
var
base
=
path
.
dirname
(
path
.
resolve
(
__dirname
,
pathToStatic
));
return
'
^
'
+
pathName
.
replace
(
base
,
''
)
+
(
path
.
extname
(
pathName
)
?
''
:
'
/
'
);
return
pathName
.
replace
(
base
,
''
)
+
(
path
.
extname
(
pathName
)
?
''
:
'
/
'
);
});
};
...
...
@@ -66,9 +66,9 @@ var expressPatternToRegex = function (pattern) {
* string suitable for a Fastly condition
*/
var
pathsToCondition
=
function
(
paths
)
{
return
'
req.url~"
'
+
paths
.
reduce
(
function
(
conditionString
,
pattern
)
{
return
'
req.url~
^(
"
'
+
paths
.
reduce
(
function
(
conditionString
,
pattern
)
{
return
conditionString
+
(
conditionString
?
'
|
'
:
''
)
+
pattern
;
},
''
)
+
'
"
'
;
},
''
)
+
'
)
"
'
;
};
/*
...
...
src/routes.json
View file @
62609cbc
...
...
@@ -2,39 +2,42 @@
{
"name"
:
"splash"
,
"pattern"
:
"^/?$"
,
"routeAlias"
:
"/?$"
,
"view"
:
"splash/splash"
,
"title"
:
"Imagine, Program, Share"
},
{
"name"
:
"about"
,
"pattern"
:
"^/about/?$"
,
"routeAlias"
:
"/about/?$"
,
"view"
:
"about/about"
,
"title"
:
"About"
},
{
"name"
:
"guidelines"
,
"pattern"
:
"^/community_guidelines/?$"
,
"routeAlias"
:
"/community_guidelines/?$"
,
"view"
:
"guidelines/guidelines"
,
"title"
:
"Scratch Community Guidelines"
},
{
"name"
:
"student-complete-registration"
,
"pattern"
:
"^/classes/complete_registration"
,
"routeAlias"
:
"
^
/classes/(complete_registration|.+/register/.+)"
,
"routeAlias"
:
"/classes/(complete_registration|.+/register/.+)"
,
"view"
:
"studentcompleteregistration/studentcompleteregistration"
,
"title"
:
"Complete your Registration"
},
{
"name"
:
"student-registration"
,
"pattern"
:
"^/classes/:id/register/:token"
,
"routeAlias"
:
"
^
/classes/(complete_registration|.+/register/.+)"
,
"routeAlias"
:
"/classes/(complete_registration|.+/register/.+)"
,
"view"
:
"studentregistration/studentregistration"
,
"title"
:
"Class Registration"
},
{
"name"
:
"conference-index"
,
"pattern"
:
"^/conference/?$"
,
"routeAlias"
:
"
^
/conference(?!/201[4-5])"
,
"routeAlias"
:
"/conference(?!/201[4-5])"
,
"view"
:
"conference/index/index"
,
"title"
:
"Scratch Conference"
,
"viewportWidth"
:
"device-width"
...
...
@@ -42,7 +45,7 @@
{
"name"
:
"conference-plan"
,
"pattern"
:
"^/conference/plan/?$"
,
"routeAlias"
:
"
^
/conference(?!/201[4-5])"
,
"routeAlias"
:
"/conference(?!/201[4-5])"
,
"view"
:
"conference/plan/plan"
,
"title"
:
"Plan Your Visit"
,
"viewportWidth"
:
"device-width"
...
...
@@ -50,7 +53,7 @@
{
"name"
:
"conference-expectations"
,
"pattern"
:
"^/conference/expect/?$"
,
"routeAlias"
:
"
^
/conference(?!/201[4-5])"
,
"routeAlias"
:
"/conference(?!/201[4-5])"
,
"view"
:
"conference/expect/expect"
,
"title"
:
"What to Expect"
,
"viewportWidth"
:
"device-width"
...
...
@@ -58,7 +61,7 @@
{
"name"
:
"conference-schedule"
,
"pattern"
:
"^/conference/schedule/?$"
,
"routeAlias"
:
"
^
/conference(?!/201[4-5])"
,
"routeAlias"
:
"/conference(?!/201[4-5])"
,
"view"
:
"conference/schedule/schedule"
,
"title"
:
"Conference Schedule"
,
"viewportWidth"
:
"device-width"
...
...
@@ -66,7 +69,7 @@
{
"name"
:
"conference-details"
,
"pattern"
:
"^/conference/:id/details/?$"
,
"routeAlias"
:
"
^
/conference(?!/201[4-5])"
,
"routeAlias"
:
"/conference(?!/201[4-5])"
,
"view"
:
"conference/details/details"
,
"title"
:
"Event Details"
,
"viewportWidth"
:
"device-width"
...
...
@@ -74,30 +77,35 @@
{
"name"
:
"developers"
,
"pattern"
:
"^/developers/?$"
,
"routeAlias"
:
"/developers/?$"
,
"view"
:
"developers/developers"
,
"title"
:
"Developers"
},
{
"name"
:
"dmca"
,
"pattern"
:
"^/DMCA/?$"
,
"routeAlias"
:
"/DMCA/?$"
,
"view"
:
"dmca/dmca"
,
"title"
:
"DMCA"
},
{
"name"
:
"educator-landing"
,
"pattern"
:
"^/educators/?$"
,
"routeAlias"
:
"/educators(?:/(faq|register|waiting))?/?$"
,
"view"
:
"teachers/landing/landing"
,
"title"
:
"Educators"
},
{
"name"
:
"teacher-faq"
,
"pattern"
:
"^/educators/faq/?$"
,
"routeAlias"
:
"/educators(?:/(faq|register|waiting))?/?$"
,
"view"
:
"teachers/faq/faq"
,
"title"
:
"Teacher Accounts FAQ"
},
{
"name"
:
"teacherregistration"
,
"pattern"
:
"^/educators/register$"
,
"routeAlias"
:
"/educators(?:/(faq|register|waiting))?/?$"
,
"view"
:
"teacherregistration/teacherregistration"
,
"title"
:
"Teacher Registration"
,
"viewportWidth"
:
"device-width"
...
...
@@ -105,98 +113,109 @@
{
"name"
:
"teacherwaitingroom"
,
"pattern"
:
"^/educators/waiting"
,
"routeAlias"
:
"/educators(?:/(faq|register|waiting))?/?$"
,
"view"
:
"teacherwaitingroom/teacherwaitingroom"
,
"title"
:
"Thank you for requesting a Scratch Teacher Account"
},
{
"name"
:
"explore"
,
"pattern"
:
"^/explore/:projects/:all/?$"
,
"routeAlias"
:
"
^
/explore(?!/ajax)"
,
"routeAlias"
:
"/explore(?!/ajax)"
,
"view"
:
"explore/explore"
,
"title"
:
"Explore"
},
{
"name"
:
"hoc"
,
"pattern"
:
"^/hoc/?$"
,
"routeAlias"
:
"/hoc/?$"
,
"view"
:
"hoc/hoc"
,
"title"
:
"Hour of Code"
},
{
"name"
:
"cards"
,
"pattern"
:
"^/info/cards/?$"
,
"routeAlias"
:
"/info/(cards|communityblocks-interviews|credits|faq)/?$"
,
"view"
:
"cards/cards"
,
"title"
:
"Cards"
},
{
"name"
:
"communityblocks-interviews"
,
"pattern"
:
"^/info/communityblocks-interviews/?$"
,
"routeAlias"
:
"/info/(cards|communityblocks-interviews|credits|faq|donate)/?$"
,
"view"
:
"communityblocks-interviews/communityblocks-interviews"
,
"title"
:
"Community Blocks Beta Tester Interviews"
},
{
"name"
:
"credits"
,
"pattern"
:
"^/info/credits/?$"
,
"routeAlias"
:
"/info/(cards|communityblocks-interviews|credits|faq)/?$"
,
"view"
:
"credits/credits"
,
"title"
:
"Credits"
},
{
"name"
:
"faq"
,
"pattern"
:
"^/info/faq/?$"
,
"routeAlias"
:
"/info/(cards|communityblocks-interviews|credits|faq)/?$"
,
"view"
:
"faq/faq"
,
"title"
:
"FAQ"
},
{
"name"
:
"jobs"
,
"pattern"
:
"^/jobs/?$"
,
"routeAlias"
:
"/jobs/?$"
,
"view"
:
"jobs/jobs"
,
"title"
:
"Jobs"
},
{
"name"
:
"privacypolicy"
,
"pattern"
:
"^/privacy_policy/?$"
,
"routeAlias"
:
"/privacy_policy/?$"
,
"view"
:
"privacypolicy/privacypolicy"
,
"title"
:
"Privacy Policy"
},
{
"name"
:
"search"
,
"pattern"
:
"^/search/:projects?$/?$"
,
"routeAlias"
:
"
^
/search"
,
"routeAlias"
:
"/search"
,
"view"
:
"search/search"
,
"title"
:
"Search"
},
{
"name"
:
"terms"
,
"pattern"
:
"^/terms_of_use/?$"
,
"routeAlias"
:
"/terms_of_use/?$"
,
"view"
:
"terms/terms"
,
"title"
:
"Scratch Terms of Use"
},
{
"name"
:
"wedo2"
,
"pattern"
:
"^/wedo/?$"
,
"routeAlias"
:
"/wedo/?$"
,
"view"
:
"wedo2/wedo2"
,
"title"
:
"LEGO WeDo 2.0"
},
{
"name"
:
"donate"
,
"pattern"
:
"^/info/donate/?"
,
"routeAlias"
:
"/info/(cards|communityblocks-interviews|credits|faq|donate)/?$"
,
"redirect"
:
"https://secure.donationpay.org/scratchfoundation/"
},
{
"name"
:
"explore-redirect"
,
"pattern"
:
"^/explore/?$"
,
"routeAlias"
:
"
^
/explore(?!/ajax)"
,
"routeAlias"
:
"/explore(?!/ajax)"
,
"redirect"
:
"/explore/projects/all"
},
{
"name"
:
"explore-projects-redirect"
,
"pattern"
:
"^/explore/projects/?$"
,
"routeAlias"
:
"
^
/explore(?!/ajax)"
,
"routeAlias"
:
"/explore(?!/ajax)"
,
"redirect"
:
"/explore/projects/all"
},
{
"name"
:
"explore-studios-redirect"
,
"pattern"
:
"^/explore/studios/?$"
,
"routeAlias"
:
"
^
/explore(?!/ajax)"
,
"routeAlias"
:
"/explore(?!/ajax)"
,
"redirect"
:
"/explore/studios/all"
}
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment