« Widget:Google Spreadsheet » : différence entre les versions

De Wiki des possibles
Aller à :navigation, rechercher
(Ajout du widget (en anglais))
 
(Correction : Ajout du Widget)
 
Ligne 1 : Ligne 1 :
{{documentation subpage}}
<noinclude>__NOTOC__
<includeonly>{{pp-template|small=yes}}</includeonly>
This widget allows you to add [[wikipedia:Google Sheets|Google Sheets]] to your wiki page.
This template creates the citation references for a Google Spreadsheet. It is intended to be used as a companion with [[Widget:Google Spreadsheet]].


Google Drive does not automatically display a chart image when viewing a wiki page. Selecting a different sheet then back again, will force the chart image to be displayed.
Add [[Template:Spreadsheet]] directly under the widget to allow readers access to the spreadsheet. The template documentation contains an example.


This template adds a note to document the above work-around.
==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>


==Usage==
Results in:
Use this template with [[Widget:Google Spreadsheet]].
{|
{{#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&amp;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
}}
|}


For example, a Google spreadsheet of the following form:
===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=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb
|pubhtml=
|width=500
|width=500
|height=300
|height=300
}}</pre>
}}</nowiki></pre>


Insert the key as: <nowiki>{{Spreadsheet|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE}}</nowiki>
Results in:
{|
{{#widget:Google Spreadsheet
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb
|pubhtml=
|width=500
|height=300
}}
|}


To produce:
===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>


{{Spreadsheet|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE}}
Parameters:
==Combine with widget==
* '''key''' - key parameter in document URL
Use this template with [[Widget:Google Spreadsheet]] to allow readers access to the spreadsheet:
* '''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
|{{#widget:Google Spreadsheet
|oid=798669522
|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE
|pubchart=
|width=750
|width=500
|height=450}}<br>
|height=300
{{spreadsheet|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE}}
}}</nowiki></pre>
|}</pre>


Results in:
Results in:
{|
{|
|-
{{#widget:Google Spreadsheet
|{{#widget:Google Spreadsheet
|key=2PACX-1vQmKS6wsrz6q34e2A7PF_4Pu7MDkChqmIQ8f8PAe-jAmQcmYx1ub-ruE--cmAql0zfI6H1PmqQbcNCb
|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE
|oid=798669522
|width=750
|pubchart=
|height=450}}<br>
|width=500
{{spreadsheet|key=0AueLhNpKZa4XdGJwNkdwdmthVXk2TjExOVd5eFUzMUE}}
|height=300
}}
|}
|}
<includeonly>
 
[[Category:Templates]]
== Security NOTE ==
</includeonly>
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&amp;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&amp;headers=false"></iframe>
 
<!--{/if}--></includeonly>
<noinclude>{{Helpful tools}}
[[Category:Widgets]]</noinclude>

Version actuelle datée du 15 novembre 2022 à 13: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.


Modèle:Helpful tools