mediawiki/alink
Composer 安装命令:
composer require mediawiki/alink
包简介
Creates custom anchor links
关键字:
README 文档
README
MediaWiki extension (type: parserhook) that provides two parser functions for rendering raw HTML <a> and <img> tags with full attribute control.
- Version: 0.3.0
- License: GPL-3.0-or-later
- Requires: MediaWiki >= 1.35.0, PHP >= 7.2
- Repository: https://github.com/SimilisTools/mediawiki-alink
Installation
- Clone or extract into
extensions/Alink/. - Add to
LocalSettings.php:wfLoadExtension( 'Alink' );
Parser functions
#alink — anchor tag
{{#alink: href=<url or wiki page> | <attributes> | <flags> | link text }}
Allowed attributes: href, rel, target, class, id, content, name, itemprop, and any data-* attribute.
Flags (no = sign):
| Flag | Effect |
|---|---|
nourlencode |
Skip urlencode() on the page name (useful for query strings with special characters) |
noprefix |
Strip namespace prefix from auto-generated link text |
Link text is the bare argument (no =). If omitted, falls back to the href value; with noprefix, falls back to the page title without namespace.
Internal vs external links: if href starts with http://, https://, or ftp://, the value is used as-is. Otherwise it is treated as a wiki page name and resolved through $wgArticlePath.
Examples
External link:
{{#alink: href=https://www.mediawiki.org | target=_blank | rel=nofollow | MediaWiki }}
Internal wiki page:
{{#alink: href=Example_page | target=_blank | Example page }}
Internal link with special characters in query string (skip URL encoding):
{{#alink: href=Special:FormEdit/Myform/Mypage?MyTemplate[Myparam]=Acción | nourlencode | Trigger action }}
Internal link, display title without namespace:
{{#alink: href=User:John_Smith | noprefix }}
With data-* attribute:
{{#alink: href=Main_Page | data-tracking=nav | Home }}
#aimg — image tag
{{#aimg: src=<url or file name> | <attributes> }}
Allowed attributes: src, rel, title, alt, class, id, content, itemprop, and any data-* attribute.
If src does not start with a recognized protocol, it is treated as a MediaWiki file name and resolved to its full URL via wfFindFile(). If the file does not exist in the wiki, src is left unchanged.
Examples
External image:
{{#aimg: src=https://example.com/logo.png | alt=Logo | class=site-logo }}
Wiki-hosted file:
{{#aimg: src=Example.png | alt=Example image | title=An example }}
Development
Install dependencies:
composer install
Lint (syntax check + executable-bit check):
composer test
Fix executable bits:
composer fix
PHP CodeSniffer (requires mediawiki/mediawiki-codesniffer installed separately):
vendor/bin/phpcs
There are no automated unit tests. Manual testing requires a running MediaWiki instance with the extension loaded.
Notes
- Output is passed through
$parser->insertStripItem()to prevent further wiki parsing of the raw HTML. - Using raw
<a>tags bypasses MediaWiki's link tracking (incoming/outgoing links are not recorded in the database). Use standard wikitext links when link tracking matters.
mediawiki/alink 适用场景与选型建议
mediawiki/alink 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 296 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「link」 「mediawiki」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mediawiki/alink 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mediawiki/alink 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mediawiki/alink 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A couple of handy form fields and objects for managing external and internal links on DataObjects
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
An extension to Semantic MediaWiki allowing to build breadcrumb links from an attributive property filter
PHP library that allows linking queries from diferent physical databases using mysql pdo database connections
Custom links on your sidebar for Laravel Nova.
Helper functions for the MediaWiki ExtensionRegistry
统计信息
- 总下载量: 296
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2014-11-13