-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JS function to annotate content with link to template on Github #2670
Merged
floehopper
merged 1 commit into
master
from
add-javascript-to-link-to-templates-on-github
Jul 28, 2016
Merged
Add JS function to annotate content with link to template on Github #2670
floehopper
merged 1 commit into
master
from
add-javascript-to-link-to-templates-on-github
Jul 28, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks good to me, @floehopper! Great work :-) |
This JavaScript relies on the `debug-template-path` data attributes made available in #2667. This idea is to call the new function from a bookmarklet or the GOV.UK Chrome extension. I wanted to add the new function in a separate file, but I couldn't get this to work. So for the moment I've added it in the existing `smart-answers.js` file. Ideally I would've added some unit tests around the function. However, we don't have any such tests at the moment, so it would be a fair bit of work. Today is my last day working on Smart Answers, I wanted to get this code live so the Content Designers could start using it. Since it's not critical functionality I think not having tests is OK for the moment.
2d994d9
to
524fe5a
Compare
Rebasing against master and force-pushing in preparation for merging. |
Note that the bookmarklet link can be found on this page. |
floehopper
added a commit
that referenced
this pull request
Aug 2, 2016
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
floehopper
added a commit
that referenced
this pull request
Aug 2, 2016
This uses the new `debug-partial-template-path` data attribute to annotate content rendered from flow *partial* templates with a link to the source template on Github. See #2670 for the "full" template version. This introduces a bunch of duplication, but I plan to remove that in a later commit.
andrewgarner
reviewed
Sep 7, 2017
@@ -171,3 +171,20 @@ $(document).ready(function() { | |||
contentPosition.init(); | |||
|
|||
}); | |||
|
|||
function linkToTemplatesOnGithub() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linkToTemplatesOnGithub linkToTemplatesOnGitHub
andrewgarner
pushed a commit
that referenced
this pull request
Nov 29, 2017
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
andrewgarner
pushed a commit
that referenced
this pull request
Nov 29, 2017
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
chao-xian
pushed a commit
that referenced
this pull request
Dec 12, 2017
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
chao-xian
pushed a commit
that referenced
this pull request
Dec 14, 2017
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
chao-xian
pushed a commit
that referenced
this pull request
Dec 16, 2017
In #2667 we started annotating the content rendered from flow templates with the path to the source template via a data attribute, `debug-template-path`. This commit annotates the content rendered from flow *partial* templates with the path to the source template via a similar data attribute, `debug-partial-template-path`. The plan is to use it in a JavaScript function like the one added in #2670 so that Content Designers can easily find the template relating to specific content in the GitHub repository. In order to achieve this, the `PartialTemplateWrapper` is wired up to `ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which were introduced in earlier commits. I've added a Rails functional test to act as an "integration" test to check everything is wired up correctly. In particular this should protect against breakages due to changes in `ActionView::PartialRenderer` and changes in govspeak or kramdown. There didn't seem much point in including the annotation in the regression test artefacts and so I've introduced an environment variable to disable the annotation in that case. This also has the benefit that I haven't had to update all the regression test artefacts which were generated using one or more partial templates.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Trello: https://trello.com/c/X7t256s9
This JavaScript relies on the
debug-template-path
data attributes made available in #2667. This idea is to call the new function from a bookmarklet or the GOV.UK Chrome extension.I wanted to add the new function in a separate file, but I couldn't get this to work. So for the moment I've added it in the existing
smart-answers.js
file.Ideally I would've added some unit tests around the function. However, we don't have any such tests at the moment, so it would be a fair bit of work.
Today is my last day working on Smart Answers, I wanted to get this code live so the Content Designers could start using it. Since it's not critical functionality I think not having tests is OK for the moment.
External changes
No visible changes. The new
linkToTemplatesOnGithub
function should be available in the browser on any page in Smart Answers.