UNC链接

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page UNC links and the translation is 52% complete.
Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎italiano • ‎polski • ‎português do Brasil • ‎العربية • ‎中文 • ‎日本語

The Universal Naming Convention, or UNC, specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. The UNC syntax for Windows systems is as follows:

\\ComputerName\Shared Folder\Resource Name

UNCs differ from URLs in that they do not have a protocol: prefix and that they can contain embedded spaces. In corporate use of MediaWiki, it is often useful to paste a UNC from Windows Explorer directly into a wiki page.

如何链接

描述 您输入的 您输出的
UNC链接,带标题 {{unc | \\ComputerName\Shared Folder\Resource Name | 资源}} 资源
UNC链接,未命名 {{unc | \\ComputerName\Shared Folder\Resource Name}} [1]

安装

安装$ParserFunctions扩展。 Follow installation instructions and add the optional "integrated string function functionality" line in LocalSettings.php by setting $wgPFEnableStringFunctions = true;. Install the extension StringFunctions (to enable #replace).

Add file:// to $wgUrlProtocols in LocalSettings.php :

array_push($wgUrlProtocols, "file://");

Create a template called Template:Unc (search for Template:Unc and click Create this page), and paste this text into the page content:

[file:///{{#replace:{{#replace:{{{1}}}| |%20}}|\|/}} {{#if:{{{2|}}}|{{{2}}}}}]

浏览器兼容性

  • With Internet Explorer on Windows UNC Links work without exception.
    • A recent patch applied to both IE8 and IE9 now requires the Wiki site to be in the Intranet Sites list for this to work correctly.
  • With Firefox file:/// links are disabled by default when appearing in non-local webpages. See: 手册:$wgUrlProtocols and this mozillaZine article for how to enable them.
    • The mozillaZine article referenced is somewhat dated. Use the Local Filesystem Links add-on for current versions of Firefox.
  • For Google Chrome file:/// links are also disabled. They can be enabled using the enable-local-file-links extension.

参见