« Widget:Google Spreadsheet » : différence entre les versions
(Ajout du widget (en anglais)) |
(Correction : Ajout du Widget) |
||
Ligne 1 : | Ligne 1 : | ||
<noinclude>__NOTOC__ | |||
This widget allows you to add [[wikipedia:Google Sheets|Google Sheets]] to your wiki page. | |||
This | |||
Add [[Template:Spreadsheet]] directly under the widget to allow readers access to the spreadsheet. The template documentation contains an example. | |||
==Usage== | |||
There are four supported URL formats. | |||
===First URL format=== | |||
The URL looks like this: | |||
<pre><nowiki>https://docs.google.com/spreadsheets/d/1pxLq_tSUlY2xEAYlK7R2pu70nT27Jn363WtlCqtAdIc/edit#gid=661167613</nowiki></pre> | |||
Parameters: | |||
* '''key''' - key parameter in document URL | |||
* '''width''' and '''height''' define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have | |||
To insert this widget, use the following code: | |||
<pre><nowiki>{{#widget:Google Spreadsheet | |||
|key=1pxLq_tSUlY2xEAYlK7R2pu70nT27Jn363WtlCqtAdIc | |||
|width=500 | |||
|height=300 | |||
}}</nowiki></pre> | |||
== | Results in: | ||
{| | |||
{{#widget:Google Spreadsheet | |||
|key=1pxLq_tSUlY2xEAYlK7R2pu70nT27Jn363WtlCqtAdIc | |||
|width=500 | |||
|height=300 | |||
}} | |||
|} | |||
===Second URL format=== | |||
The second format has a URL which looks like this: | |||
<pre><nowiki>https://docs.google.com/spreadsheets/d/e/2PACX-1vRhM_MeJnMphY5A1zuOvAr7IL2Jj41Qg51Scd6MoNj0TIjC2LHVqjUwudbIwa-26Ulgh1kzzTTLBfif/pubchart?oid=226162492&?widget=true&headers=false</nowiki></pre> | |||
Parameters: | Parameters: | ||
* key | * '''key''' - key parameter in document URL | ||
* '''oid''' - object ID in document URL | |||
* '''width''' and '''height''' define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have | |||
<pre><nowiki>{{#widget:Google Spreadsheet | |||
|key=2PACX-1vRhM_MeJnMphY5A1zuOvAr7IL2Jj41Qg51Scd6MoNj0TIjC2LHVqjUwudbIwa-26Ulgh1kzzTTLBfif | |||
|oid=226162492 | |||
|width=500 | |||
|height=300 | |||
}}</nowiki></pre> | |||
Results in: | |||
{| | |||
{{#widget:Google Spreadsheet | |||
|key=2PACX-1vRhM_MeJnMphY5A1zuOvAr7IL2Jj41Qg51Scd6MoNj0TIjC2LHVqjUwudbIwa-26Ulgh1kzzTTLBfif | |||
|oid=226162492 | |||
|width=500 | |||
|height=300 | |||
}} | |||
|} | |||
===Third URL format=== | |||
The third format has a URL which looks like this: | |||
<pre><nowiki>https://docs.google.com/spreadsheets/d/e/2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb/pubhtml</nowiki></pre> | |||
Parameters: | |||
* '''key''' - key parameter in document URL | |||
* '''pubhtml''' - must be present and blank | |||
* '''width''' and '''height''' define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have | |||
<pre>{{#widget:Google Spreadsheet | <pre><nowiki>{{#widget:Google Spreadsheet | ||
|key= | |key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb | ||
|pubhtml= | |||
|width=500 | |width=500 | ||
|height=300 | |height=300 | ||
}}</pre> | }}</nowiki></pre> | ||
Results in: | |||
{| | |||
{{#widget:Google Spreadsheet | |||
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb | |||
|pubhtml= | |||
|width=500 | |||
|height=300 | |||
}} | |||
|} | |||
===Fourth URL format=== | |||
The fourth format has a URL which looks like this: | |||
<pre>https://docs.google.com/spreadsheets/d/e/2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb/pubchart?oid=798669522&format=interactive</pre> | |||
Parameters: | |||
* '''key''' - key parameter in document URL | |||
* '''oid''' - object ID in document URL | |||
* '''pubchart''' - must be present and blank | |||
* '''width''' and '''height''' define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have | |||
<pre> | <pre><nowiki>{{#widget:Google Spreadsheet | ||
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb | |||
|oid=798669522 | |||
|key= | |pubchart= | ||
|width= | |width=500 | ||
|height= | |height=300 | ||
}}</nowiki></pre> | |||
Results in: | Results in: | ||
{| | {| | ||
{{#widget:Google Spreadsheet | |||
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb | |||
|key= | |oid=798669522 | ||
|width= | |pubchart= | ||
|height= | |width=500 | ||
|height=300 | |||
}} | |||
|} | |} | ||
<includeonly> | |||
[[Category: | == Security NOTE == | ||
</ | Keep in mind that to use this widget you must make the document you're publishing to be open for everybody to see which might be undesirable for some uses (intranets, closed groups and etc.) | ||
==Widget internals== | |||
Documentation for this widget can be found at [https://www.mediawikiwidgets.org/Google_Spreadsheet MediaWiki Widgets]. | |||
The first URL format is based on the Google Sheets "Embed" code shown in [https://en.support.wordpress.com/google-docs/#sheets Google Docs — Support — WordPress.com]. | |||
Subsequent formats are based on actual URLs. | |||
Widgets do not use [[mw:Help:Magic_words#Parser_functions|parser functions]]. Instead, a template programming language known as "Smarty" is used. Refer to the [https://www.smarty.net/docs/en/ Smarty 3 Manual] for the details. | |||
</noinclude><includeonly><!--{if (not isset($oid)) and (not isset($pubhtml)) and (not isset($pubchart))}--> | |||
<iframe width="<!--{$width|escape:'html'|default:500}-->" height="<!--{$height|escape:'html'|default:300}-->" frameborder="0" src="//docs.google.com/spreadsheets/d/<!--{$key|escape:'urlpathinfo'}-->/pubhtml?widget=true&headers=false"></iframe> | |||
<!--{elseif isset($pubhtml)}--> | |||
<iframe width="<!--{$width|escape:'html'|default:500}-->" height="<!--{$height|escape:'html'|default:300}-->" frameborder="0" src="//docs.google.com/spreadsheets/d/e/<!--{$key|escape:'urlpathinfo'}-->/pubhtml"></iframe> | |||
<!--{elseif isset($pubchart)}--> | |||
<iframe width="<!--{$width|escape:'html'|default:500}-->" height="<!--{$height|escape:'html'|default:300}-->" frameborder="0" src="//docs.google.com/spreadsheets/d/e/<!--{$key|escape:'urlpathinfo'}-->/pubchart?oid=<!--{$oid|escape:'urlpathinfo'}-->&format=interactive"></iframe> | |||
<!--{else}--> | |||
<iframe width="<!--{$width|escape:'html'|default:500}-->" height="<!--{$height|escape:'html'|default:300}-->" frameborder="0" src="//docs.google.com/spreadsheets/d/e/<!--{$key|escape:'urlpathinfo'}-->/pubchart?oid=<!--{$oid|escape:'urlpathinfo'}-->&?widget=true&headers=false"></iframe> | |||
<!--{/if}--></includeonly> | |||
<noinclude>{{Helpful tools}} | |||
[[Category:Widgets]]</noinclude> |
Version actuelle datée du 15 novembre 2022 à 12:42
This widget allows you to add Google Sheets to your wiki page.
Add Template:Spreadsheet directly under the widget to allow readers access to the spreadsheet. The template documentation contains an example.
Usage
There are four supported URL formats.
First URL format
The URL looks like this:
https://docs.google.com/spreadsheets/d/1pxLq_tSUlY2xEAYlK7R2pu70nT27Jn363WtlCqtAdIc/edit#gid=661167613
Parameters:
- key - key parameter in document URL
- width and height define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have
To insert this widget, use the following code:
{{#widget:Google Spreadsheet |key=1pxLq_tSUlY2xEAYlK7R2pu70nT27Jn363WtlCqtAdIc |width=500 |height=300 }}
Results in:
Second URL format
The second format has a URL which looks like this:
https://docs.google.com/spreadsheets/d/e/2PACX-1vRhM_MeJnMphY5A1zuOvAr7IL2Jj41Qg51Scd6MoNj0TIjC2LHVqjUwudbIwa-26Ulgh1kzzTTLBfif/pubchart?oid=226162492&?widget=true&headers=false
Parameters:
- key - key parameter in document URL
- oid - object ID in document URL
- width and height define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have
{{#widget:Google Spreadsheet |key=2PACX-1vRhM_MeJnMphY5A1zuOvAr7IL2Jj41Qg51Scd6MoNj0TIjC2LHVqjUwudbIwa-26Ulgh1kzzTTLBfif |oid=226162492 |width=500 |height=300 }}
Results in:
Third URL format
The third format has a URL which looks like this:
https://docs.google.com/spreadsheets/d/e/2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb/pubhtml
Parameters:
- key - key parameter in document URL
- pubhtml - must be present and blank
- width and height define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have
{{#widget:Google Spreadsheet |key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb |pubhtml= |width=500 |height=300 }}
Results in:
Fourth URL format
The fourth format has a URL which looks like this:
https://docs.google.com/spreadsheets/d/e/2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb/pubchart?oid=798669522&format=interactive
Parameters:
- key - key parameter in document URL
- oid - object ID in document URL
- pubchart - must be present and blank
- width and height define spreadsheet dimensions, 500x300 is default, but you might want to copy it from embed code since size depends on fields you have
{{#widget:Google Spreadsheet |key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb |oid=798669522 |pubchart= |width=500 |height=300 }}
Results in:
Security NOTE
Keep in mind that to use this widget you must make the document you're publishing to be open for everybody to see which might be undesirable for some uses (intranets, closed groups and etc.)
Widget internals
Documentation for this widget can be found at MediaWiki Widgets.
The first URL format is based on the Google Sheets "Embed" code shown in Google Docs — Support — WordPress.com.
Subsequent formats are based on actual URLs.
Widgets do not use parser functions. Instead, a template programming language known as "Smarty" is used. Refer to the Smarty 3 Manual for the details.