User:Invadibot/scope/meta-2

From Meta, a Wikimedia project coordination wiki
This page is a translated version of the page User:Invadibot/scope/meta-2 and the translation is 100% complete.

목표

이 작업의 목표는 다음과 같습니다:

  • 사용자가 사용중인 프로토콜을 변경하지 않고 탐색 할 수 있도록 외부 링크 형식 및 HTTP 정의 프로토콜이있는 링크에 프로토콜 기준 URL을 적용합니다.
  • 추가로, 외부 링크 형식의 링크를 수정하고 인터위키 형식으로 변환합니다. 단, 이 변경은 표시 할 텍스트를 수정하지 않습니다.

모든 혼합 콘텐츠 경고를 수정하는 것은 미디어위키 코어 및 확장 개발자와 프로젝트 커뮤니티 모두의 오랜 노력이 될 것입니다. 프로젝트의 많은 틀과 CSS 및 자바스크립트가 리소스를 부적절하게 참조하고 있어 잘못 로드되고 있습니다. 이제 모든 리소스는 프로토콜 기준 URL을 사용하여 참조되어야합니다 (//<resource-url> vs http://<resource-url>).

[...]

콘텐츠의 모든 링크가 프로토콜 별 링크에서 프로토콜 별 링크로 변경되었습니다. 이 콘텐츠는 squid 레이어와 파서 캐시에 캐시됩니다. 심각한 성능 문제를 일으킬 수 있으므로 이 문제를 해결하기 위해 전체 캐시를 즉시 지우고 싶지 않습니다. 대신 시간이 지남에 따라 캐시를 천천히 지우거나 자연스럽게 지울 것입니다.

절차: 변경 조건

프로토콜 기준 URL 적용

링크가 발견되면 프로토콜 기준 URL이 적용됩니다(모든 조건 필요):

  • 다음을 의미하는 외부 링크 형식이 있습니다:
    • 단일 대괄호 사이 그리고
    • URL로 시작합니다.
  • HTTP 정의 프로토콜 (HTTPS 아님)이 있습니다;
  • (wikipedia/wikinews/wikisource/wikibooks/wikiquote/wikiversity/wiktionary/wikivoyage/wikidata/wikimedia/wikimediafoundation/mediawiki).org 도메인 이름을 가리키며 대소 문자를 구분합니다;
  • 이 태그 안에는 없습니다: categorytree, comment, charinsert, dynamicpagelist, gallery, hiero, imagemap, inputbox, invoke, math, nowiki, pagelist, pagequality, pages, poem, pre, property, score, section, source, syntaxhighlight, templatedata, timeline;
  • 예외 목록에 없고 페이지도 없습니다.

인터위키 형식 적용

링크가 발견되면 인터위키 형식도 적용됩니다(모든 조건 필요):

  • 다음을 의미하는 외부 링크 형식이 있습니다:
    • 단일 대괄호 사이 그리고
    • URL로 시작합니다.
  • HTTPS 정의 프로토콜이 없습니다;
  • (wikipedia/wikinews/wikisource/wikibooks/wikiquote/wikiversity/wiktionary/wikivoyage/wikidata/wikimedia/wikimediafoundation/mediawiki).org 도메인 이름을 가리키며 대소 문자를 구분합니다;
  • 이 태그 안에 없습니다: categorytree, comment, charinsert, dynamicpagelist, gallery, hiero, imagemap, inputbox, invoke, math, nowiki, pagelist, pagequality, pages, poem, pre, property, score, section, source, syntaxhighlight, templatedata, timeline;
  • 표시 할 정의 된 텍스트가 있습니다. 즉, URL 뒤에 공백으로 구분 된 일부 텍스트가 포함되어 있습니다;
  • 표준 URL 형식이 없습니다;
  • /wiki/ 경로 뒤에 정의 된 페이지를 가리 킵니다;
  • 예외 목록에 없고 페이지도 없습니다.

범위

이 작업이 수행하는 변경 사항은 Wiki의 모든 편집 가능한 페이지에서 수행 할 수 있습니다. 사용자가 HTTP 또는 HTTPS로 탐색 할 수 있도록하고 탐색과 함께 사용중인 프로토콜을 유지하기 위해 필요합니다.

코드

이 작업에 사용 된 정규 표현식은 user-fixes.py 파일에서 Pywikipediabot으로 실행할 준비가 되어 있으며 여기에서 사용할 수 있습니다:

# -*- coding: utf-8 -*-
# <nowiki>
fixes['wmp-prurls'] = {
     # ----
     # From <https://meta.wikimedia.org/wiki/User:Invadibot/scope/meta-2/user-fixes.py>.
     # By David Abián and Roan Kattouw.
     # ----
     # This program is free software: you can redistribute it and/or modify
     # it under the terms of the GNU General Public License as published by
     # the Free Software Foundation, either version 3 of the License, or
     # (at your option) any later version.
     # 
     # This program is distributed in the hope that it will be useful,
     # but WITHOUT ANY WARRANTY; without even the implied warranty of
     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     # GNU General Public License for more details, 
     # <http://www.gnu.org/licenses/>.
     # ----
     # To debug this script, please go to
     # <https://meta.wikimedia.org/wiki/User:Invadibot/scope/meta-2/user-fixes.py>.
     # The goals and procedures are explained in
     # <https://meta.wikimedia.org/wiki/User:Invadibot/scope/meta-2>.
     # ----
     # Thanks for your help!
     # ----
     'nocase': False,
     'recursive': True,
     'regex': True,
     'msg': {
          # Please add an edit summary for your project,
          # if not defined, and update the script in
          # <https://meta.wikimedia.org/wiki/User:Invadibot/scope/meta-2/user-fixes.py>.
          'an':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Apanyando vinclos enta prochectos Wikipedia y aplicando adrezas URL de protocolo relativo',
          'en':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Fixing links to Wikimedia projects and applying protocol-relative URLs',
          'es':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Arreglando enlaces a proyectos Wikimedia y aplicando direcciones URL de protocolo relativo',
          'fa':u'[[:m:User:Invadibot/scope/meta-2|ربات]]: تصحیح پیوند به پروژه‌های خواهر و تبدیل کردن پیوندها به خنثی در برابر پروتکل',
          'foundation':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Fixing links to Wikimedia projects and applying protocol-relative URLs',
          'gl':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Arranxando ligazóns a proxectos Wikimedia e aplicando enderezos URL de protocolo relativo',
          'meta':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Fixing links to Wikimedia projects and applying protocol-relative URLs',
          'test':u'[[:m:User:Invadibot/scope/meta-2|Bot]]: Testing links to Wikimedia projects',
     },
     'replacements': [
          (ur'\[http://([^@:/ ]+\.)wik(ipedia|inews|isource|ibooks|iquote|iversity|tionary|idata|ivoyage|imedia)\.org/', ur'[//\1wik\2.org/'),
          (ur'\[http://wik(ipedia|inews|isource|ibooks|iquote|iversity|tionary|idata|ivoyage|imedia)\.org/', ur'[//wik\1.org/'),
          (ur'\[http://(www\.)?mediawiki\.org/', ur'[//\1mediawiki.org/'),
          (ur'\[http://(www\.)?wikimediafoundation\.org/', ur'[//\1wikimediafoundation.org/'),
          (ur'\[//(www\.)?mail\.wikipedia\.org/', ur'[//lists.wikimedia.org/'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikipedia\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:w:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikinews\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:n:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikisource\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:s:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikibooks\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:b:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikiquote\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:q:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikiversity\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:v:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wiktionary\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:wikt:\2:\3|\4]]'),
          (ur'\[//(www\.)?([^@:/ (www)]+)\.wikivoyage\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:wikivoyage:\2:\3|\4]]'),
          (ur'\[//(www\.)?wikidata\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:d:\2|\3]]'),
          (ur'\[//(www\.)?mediawiki\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:mw:\2|\3]]'),
          (ur'\[//(www\.)?wikimediafoundation\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:wmf:\2|\3]]'),
          (ur'\[//(www\.)?meta\.wikimedia\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:m:\2|\3]]'),
          (ur'\[//(www\.)?outreach\.wikimedia\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:outreach:\2|\3]]'),
          (ur'\[//(www\.)?wikitech\.wikimedia\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:wikitech:\2|\3]]'),
          (ur'\[//(www\.)?commons\.wikimedia\.org/wiki/([^\s\]\?\|]+) ([^\]]+)\]', ur'[[:commons:\2|\3]]'),
          (ur'\[http://toolserver\.org/', ur'[//toolserver.org/'),
          #
          # One of the next lines can be uncommented and adjusted depending
          # on the project in which this script is going to run.
          #
          #(ur'\[\[:?m:([^\]]+)\]\]', ur'[[:\1]]'),        # Meta-Wiki
          #(ur'\[\[:?d:([^\]]+)\]\]', ur'[[:\1]]'),        # Wikidata
          #(ur'\[\[:?mw:([^\]]+)\]\]', ur'[[:\1]]'),       # MediaWiki
          #(ur'\[\[:?outreach:([^\]]+)\]\]', ur'[[:\1]]'), # Outreach
          #(ur'\[\[:?commons:([^\]]+)\]\]', ur'[[:\1]]'),  # Commons
          #(ur'\[\[:?wikitech:([^\]]+)\]\]', ur'[[:\1]]'), # Wikitech
          #(ur'\[\[:?w:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikipedia (replace "en" by the language code)
          #(ur'\[\[:?n:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikinews (replace "en" by the language code)
          #(ur'\[\[:?s:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikisource (replace "en" by the language code)
          #(ur'\[\[:?b:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikibooks (replace "en" by the language code)
          #(ur'\[\[:?q:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikiquote (replace "en" by the language code)
          #(ur'\[\[:?v:en:([^\]]+)\]\]', ur'[[:\1]]'),     # Wikiversity (replace "en" by the language code)
          #(ur'\[\[:?wikt:en:([^\]]+)\]\]', ur'[[:\1]]'),  # Wiktionary (replace "en" by the language code)
          #(ur'\[\[:?wikivoyage:en:([^\]]+)\]\]', ur'[[:\1]]'), # Wikivoyage (replace "en" by the language code)
          #(ur'\[\[:?(foundation|wikimedia|wmf):([^\]]+)\]\]', ur'[[:\2]]'), # Foundation Wiki
          #
     ],
     'exceptions': {
          'title': [
               '\.(css|js|php|py|sh)',
               '([Bb]lack|[Gg]r[ae]y|[Ww]hite)[ _]?[Ll]ist',
               '([Ss]abliera|[Ss]and[ _]?([Bb]ox|[Pp]ut|[Cc]haschte|[Kk]assen?|[Kk]assinn|[Ll][aå]dan)|([Zz]ona|[Pp][aáà](g|ch)ina)[ _]?de[ _]?([Pp]r(ue[bv]as?|o[bv][ae]s|e[bv]atinas?)|[Tt]estes?))', # You can occasionally comment this line for testing purposes.
               u'(صفحه[ _]تمرین|گودال)', #for Persian, no need to make it very general
          ],
          'inside': [
               (ur'\[//(www\.)?([^@:/ (www)]+)\.[a-z]+\.org/wiki/[^\s\]\?\|]+ (.*?\[\[.*?\]\].*?)+\]'),
               (ur'\[//.{500}.*?\]'),
               (ur'\[http://(www\.)?(apt|bayes|bayle|brewster|commonsprototype\.tesla\.usability|commons\.prototype|cs|cz|dataset2|de\.prototype|download|dumps|ekrem|emery|en\.prototype|ersch|etherpad|fenari|flaggedrevssandbox|flgrevsandbox|gallium|ganglia|ganglia3|harmon|hume|ipv4\.labs|ipv6and4\.labs|jobs|mlqt\.tesla\.usability|mobile\.tesla\.usability|m|nagios|noboard\.chapters|noc|observium|oldusability|project2|prototype|results\.labs|search|sitemap|snapshot3|stafford|stats|status|svn|test\.prototype|torrus|ubuntu|wiki-mail|yongle)\.wikimedia\.org'),
               (ur'\[http://(www\.)?(arbcom\.[a-z]+|download|m|static|wg\.[a-z]+)\.wikipedia\.org'),
               (ur'\[http://(www\.)?[^@:/]+\.m\.wikipedia\.org'),
               (ur'\[//(www\.)?(ten|test|test2)\.wikipedia\.org'), # To prevent: test.wikipedia -> [[w:test:]]
          ],
         'inside-tags': [
               # You can occasionally comment some of these exception tags,
               # under your own risk.
               'categorytree',
               'comment',
               'charinsert',
               'dynamicpagelist',
               'gallery',
               'hiero',
               'imagemap',
               'inputbox',
               'invoke',
               'math',
               'nowiki',
               'pagelist',
               'pagequality',
               'pages',
               'poem',
               'pre',
               'property',
               'score',
               'section',
               'source',
               'syntaxhighlight',
               'templatedata',
               'timeline',
          ]
     }
}
# </nowiki>