확장 기능:UseResource
이 확장 기능은 미디어위키 1.45 또는 후속 버전과 호환되지 않습니다! 미디어위키 개발자는 {{Incompatible}} 틀을 {{Incompatible|version=1.45|pledge=~~~~}}로 교체하여 미디어위키 1.46와 호환되도록 이 확장 기능을 업데이트하는 노력을 약속하도록 초대됩니다. |
출시 상태: 안정 |
|
|---|---|
| 구현 | 태그 |
| 설명 | JS와 CSS를 미디어위키 이름공간에 문서마다 로드합니다. |
| 만든 이 | Brandon Fowler (BrandonXLF토론) |
| 최신 버전 | 1.0.0 |
| 호환성 정책 | 스냅샷은 미디어위키와 함께 릴리스됩니다. Master is not backward compatible. |
| MediaWiki | 1.35+ |
| PHP | 7+ |
|
<usestyle src=...>...</usestyle> |
|
| Licence | GNU General Public License 2.0 or later |
| 다운로드 | |
| UseResource 확장 기능 번역 (translatewiki.net에서 가능한 경우) | |
| 이슈 | 미해결 작업 · 버그 보고 |
The UseResource extension adds the <usescript> and <usestyle> tags that allow JavaScript and CSS to be loaded from the MediaWiki namespace on a per-page basis.
When used in a template, pages that use the template will load the JS/CSS, this allows for the loading of scripts and stylesheets only used on some pages to be only loaded on the pages they are used on rather than being loaded on all pages using MediaWiki:Common.js and MediaWiki:Common.css or Extension:Gadgets.
Scripts can only be loaded from the MediaWiki namespace to prevent malicious code from being run, if you desire a way for user to edit stylesheets that only affect the content area, see Extension:TemplateStyles.
설치
- 파일을 다운로드하고
UseResource폴더를extensions/디렉토리에 넣어 주세요.
개발자와 코딩 기여자는 Git을 이용해 확장기능을 다운받는 것이 좋습니다.cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UseResource
- 아래의 코드를 LocalSettings.php 코드의 마지막에 추가합니다.
wfLoadExtension( 'UseResource' );
완료 – 위키의 ‘Special:Version’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.
사용법
The extension is used by including <usescript src="..." /> or <usestyle src="..." /> tags on wiki pages to load the resource (script or stylesheet), replacing ... with the name of the resource.
Resources must be located in the MediaWiki namespace and can only be edited by uses with the editinterface user right as they are the only users allowed to edit pages in the MediaWiki namespace.
The value of the src attribute is the name of the resource to load.
If no namespace is included, the MediaWiki namespace is assumed.
For example, if you had a script located at MediaWiki:Test.js, you could load it using <usescript src="test.js" />.
This will fail if the requested script does not exist, is not located in the MediaWiki namespace, or if it does not have the correct content model, JavaScript for scripts and CSS for stylesheets.
If the same resource is included on a single page multiple times, it is only run once.
