Skip to content
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
merged 1 commit into from
Jul 28, 2016

Conversation

floehopper
Copy link
Contributor

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.

@chrisroos
Copy link
Contributor

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.
@floehopper floehopper changed the title Add function to annotate content with link to template on Github Add JS function to annotate content with link to template on Github Jul 28, 2016
@floehopper floehopper force-pushed the add-javascript-to-link-to-templates-on-github branch from 2d994d9 to 524fe5a Compare July 28, 2016 15:28
@floehopper
Copy link
Contributor Author

Rebasing against master and force-pushing in preparation for merging.

@floehopper floehopper merged commit d5846b2 into master Jul 28, 2016
@floehopper floehopper deleted the add-javascript-to-link-to-templates-on-github branch July 28, 2016 15:32
@floehopper
Copy link
Contributor Author

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.
@@ -171,3 +171,20 @@ $(document).ready(function() {
contentPosition.init();

});

function linkToTemplatesOnGithub() {
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants