利用者:Nijcadmin

提供:脳科学辞典
2012年1月12日 (木) 00:12時点におけるNijcadmin (トーク | 投稿記録)による版

ナビゲーションに移動 検索に移動

2012年1月11日(水)

FCKEditor で ref タグの中の pubmed タグがエスケープされてしまう

  • extensions/FCKeditor/plugins/mediawiki/fckplugin.js を以下のように修正
case 'fck_mw_ref' :
        var refName = htmlNode.getAttribute( 'name' ) ;

        stringBuilder.push( '<ref' ) ;

        if ( refName && refName.length > 0 )
                stringBuilder.push( ' name="' + refName + '"' ) ;

        if ( htmlNode.innerHTML.length == 0 )
                stringBuilder.push( ' />' ) ;
        else
        {
                stringBuilder.push( '>' ) ;
                // NIJC:
                //stringBuilder.push( htmlNode.innerHTML ) ;
                var refInnerHTML = htmlNode.innerHTML.replace( /&lt;pubmed&gt;/g, '<pubmed>' ).replace( /&lt;\/pubmed&gt;/g, '</pubmed>' ) ;
                stringBuilder.push( refInnerHTML ) ;
                stringBuilder.push( '</ref>' ) ;
        }
        return ;

2012年1月4日(水)

SyntaxHighlight GeSHi の導入

Pubmed プラグイン利用時に表示が遅い

  • キャッシュ機能はキーワードを元に pubmed に問い合わせて得られた結果の pmid をキャッシュしているため,表示毎に<pubmed>...</pubmed>の数だけ通信が発生する.
  • 対策として pubmed に問い合わせる前段階でキャッシュする機能を実装.
  • extensions/Pubmed/entrez.cl/entrez_eutil_nijc.class.php
<?php

class entrez_eutils_nijc extends entrez_eutils_fcgi {
        // constructor
        function entrez_eutils_nijc() {
                parent::entrez_eutils_fcgi();
        }

        // override search2 method
        function search2($db, $term, $off=0, $limit=500) {
                global $wgPubmedCacheExpire;
                if (empty($this->_cache))
                        return parent::search2($db, $term, $off, $limit);
                $cache = new Cache();
                $cache->cachedir = $this->_cache;
                $filename = sprintf('esearch_%s', md5($term));
                $now = time();
                $expire = 604800; // 86400:1day, 604800:1 week
                if (isset($wgPubmedCacheExpire))
                        $expire = intval($wgPubmedCacheExpire);
                if ($cache->check($filename)) {
                        $data = $cache->load($filename);
                        if ($data['date'] + $expire >= $now)
                                return $data['value'];
                }
                $data = array(
                        'date' => $now,
                        'value' => parent::search2($db, $term, $off, $limit),
                );
                $cache->save($filename, $data);
                return $data['value'];
        }
}
  • extension/Pubmed/Pubmed.php
require_once("entrez.cl/entrez_eutil.class.php");
// NIJC:
require_once("entrez.cl/entrez_eutil_nijc.class.php");
include("layout.inc.php");
...
        // NIJC:
        //$ncbi = new entrez_eutils_fcgi();
        $ncbi = new entrez_eutils_nijc();
  • LocalSettings.php
$wgPubmedCacheExpire = 604800; // 1week yo 12/1/4

Pubmed 文献の参考文献の際,参照番号の右に著者を表示したい

  • レイアウトテンプレートを修正
    • extension/Pubmed/layouts/layout_ext.def
<b>##Authors##</b>
<p style=" border:none; outset none; margin:0em; padding:0em; background-color:#fff;">
##Title## <br>
<i>##Journal##</i>: ##Year##, ##Volume##(##Issue##);##Pages## ##PMID## ##WORLDCAT## ##DOI## <br>
</p>

2011年12月15日(木)

ページ毎に meta タグに入れるキーワードを設定したい

  • 前日に作った拡張 AddKeywordsMetaTag に この機能 をマージ
<?php

$wgExtensionCredits['other'][] = array( 
  'name' => 'AddKeywordsMetaTag', 
  'status' => 'Experimental',
  'author' => 'Yoshihiro OKUMURA',
  'version' => '2.0',
  'url' => 'http://www.neuroinf.jp/',
  'description' => 'Add keywords into meta tag',
);
$wgHooks['OutputPageBeforeHTML'][] = 'wfAddKeywordsMetaTag';
$wgExtensionFunctions[] = 'wfAddKeywordsMetaTagParserHooks';
 
function wfAddKeywordsMetaTagParserHooks() {
  global $wgParser, $wgMessageCache;
  $wgParser->setHook( 'keywords', 'wfAddKeywordsMetaTagRender' );
  $wgMessageCache->addMessage(
    'metakeywordstag-missing-content', 
    'Error: &lt;keywords&gt; tag must contain a &quot;content&quot; attribute.'
  );
}
 
function wfAddKeywordsMetaTagRender($text, $params = array(), $parser) {
  // Short-circuit with error message if content is not specified.
  if (!isset($params['content'])) {
    return '<div class="errorbox">'.
           wfMsgForContent('metakeywordstag-missing-content').
           '</div>';
  }
  // Return encoded content
  return '<!-- META_KEYWORDS '.base64_encode($params['content']).' -->';
}
 
function wfAddKeywordsMetaTag(&$out, &$text) {
  global $wgTitle, $wgParser, $wgRequest, $action;
  if ($action !== 'edit' &&
      $action !== 'history' &&
      $action !== 'delete' &&
      $action !== 'watch') {
    // Mediawiki:Keywords
    $title = Title::MakeTitle(NS_MEDIAWIKI, 'Keywords');
    $article = new Article($title);
    $keywords = array_map('trim', explode(',', $article->getRawText()));
    foreach ($keywords as $keyword) 
      if (!empty($keyword))
        $out->addKeyword($keyword);
    $namespaces = array(NS_MAIN, NS_USER, NS_PROJECT, NS_MEDIAWIKI);
    foreach ($namespaces as $namespace) {
      // Mediawiki::Keywords-$namespace
      if ($wgTitle->getNamespace() === $namespace) {
        $page = sprintf('Keywords-%u', $namespace);
        $title = Title::MakeTitle(NS_MEDIAWIKI, $page);
        $article = new Article($title);
        $keywords = array_map('trim', explode(',', $article->getRawText()));
        foreach ($keywords as $keyword) 
          if (!empty($keyword))
            $out->addKeyword($keyword);
      }
    }
  }
  // part of MetaKeywordsTag.php
  if (preg_match_all('/<!-- META_KEYWORDS ([0-9a-zA-Z\\+\\/]+=*) -->/m', $text, $matches)) {
    $data = $matches[1];
    // Merge keyword data into OutputPage as meta tags
    foreach ($data aS $item) {
      $content = @base64_decode($item);
      $keywords = array_map('trim', explode(',', $content));
      foreach ($keywords as $keyword) 
        if (!empty($keyword))
          $out->addKeyword($keyword);
    }
  }
  return true;
}

2011年12月14日(水)

FCKEditor を使うと図のキャプションが消える.

使用前 [[Image:Differentialdisplay.jpg|thumb|テスト]]
使用後 [[Image:Differentialdisplay.jpg|thumb]]
  • extensions/FCKeditor/FCKeditorSkin.body.php を上記を参考に以下のように修正
// NIJC:
//if (isset($fp['alt']) && !empty($fp['alt']) && $fp['alt'] != "Image:" . $orginal) {
//        $ret .= "alt=\"".htmlspecialchars($fp['alt'])."\" ";
if (isset($fp['caption']) && !empty($fp['caption']) && $fp['caption'] != "Image:" . $orginal) {
        $ret .= "alt=\"".htmlspecialchars($fp['caption'])."\" ";
}

keywords meta タグを入れたい

  • extension/AddKeywordsMetaTag.php を作ってみた.
<?php

$wgExtensionCredits['other'][] = array( 
  'name' => 'AddKeywordsMetaTag', 
  'status' => 'Experimental',
  'author' => 'Yoshihiro OKUMURA',
  'version' => '1.0',
  'url' => 'http://www.neuroinf.jp/',
  'description' => 'Mediawiki:Keywords ページの内容を keywords meta タグとして出力します.',
);
$wgHooks['OutputPageBeforeHTML'][] = 'wfAddKeywordsMetaTag';
 
function wfAddKeywordsMetaTag(&$out, &$text) {
 global $wgTitle, $wgParser, $wgRequest, $action;
  if ($action !== 'edit' &&
      $action !== 'history' &&
      $action !== 'delete' &&
      $action !== 'watch') {
    // Mediawiki:Keywords
    $title = Title::MakeTitle(NS_MEDIAWIKI, 'Keywords');
    $article = new Article($title);
    $keywords = array_map('trim', explode(',', $article->getRawText()));
    foreach ($keywords as $keyword) 
      if (!empty($keyword))
        $out->addKeyword($keyword);
    $namespaces = array(NS_MAIN, NS_USER, NS_PROJECT, NS_MEDIAWIKI);
    foreach ($namespaces as $namespace) {
      // Mediawiki::Keywords-$namespace
      if ($wgTitle->getNamespace() === $namespace) {
        $page = sprintf('Keywords-%u', $namespace);
        $title = Title::MakeTitle(NS_MEDIAWIKI, $page);
        $article = new Article($title);
        $keywords = array_map('trim', explode(',', $article->getRawText()));
        foreach ($keywords as $keyword) 
          if (!empty($keyword))
            $out->addKeyword($keyword);
      }
    }
  }
  return true;
}

2011年12月12日(月)

FCKEditor を使うとwikipediaへのリンクが符号化される.

使用前 [[wikipedia:jp:理化学研究所|理化学研究所]]
使用後 [[wikipedia:jp:%E7%90%86%E5%8C%96%E5%AD%A6%E7%A0%94%E7%A9%B6%E6%89%80|理化学研究所]]
  • extensions/FCKeditor/plugins/mediawiki/fckplugin.js を以下のように修正
if (a.className == 'extiw')
{
        a.href = a.title ;
        // NIJC:
        // a.setAttribute( '_fcksavedurl', a.href ) ;
        a.setAttribute( '_fcksavedurl', a.title ) ;
}

2011年12月7日(水)

metaタグ index,follow の制御が効かない.

  • 承認モジュール ApprovedRevs 由来の問題 参考
  • includes/Article.php を以下のように修正
// NIJC:
//if ( $this->getID() === 0 || $this->getOldID() ) {
if ( $this->getID() === 0 || $this->getOldID() == intval( @$_GET['oldid'] ) ) {
        # Non-articles (special pages etc), and old revisions
        return array( 'index'  => 'noindex',
                      'follow' => 'nofollow' );
} elseif ( $wgOut->isPrintable() ) {

2011年6月15日 (水)

設定変更

2011年6月7日 (火)

サーバ準備

  • ホスト名: bsd.neuroinf.jp (仮)
  • OS: Linux CentOS 5.6 x86_64

MediaWiki 導入

  • MediaWiki 1.16.5 インストール
    • 言語は日本語(ja)を利用
    • ドキュメントのライセンスを無難なセンでCC-BY-SA Japanに設定 (仮)
  • Short_URL 設定
  • ロゴ画像設置(仮)
    • これをベースに文字を入れ替えたものに
 $wgLogo             = "$wgScriptPath/images/BSD-Logo.png";
  • 画像アップロードの設定
 $wgEnableUploads       = true;
 $wgUploadPath          = "{$wgScriptPath}/images";
 $wgUploadDirectory     = "{$IP}/images";
 $wgUseImageMagick      = true;
 $wgImageMagickConvertCommand = "/usr/bin/convert";
 $wgUseTeX           = true;
 $wgTexvc            = "/usr/bin/texvc116";
 $wgMathPath         = "{$wgUploadPath}/math";
 $wgMathDirectory    = "{$wgUploadDirectory}/math";
 $wgTmpDirectory     = "{$wgUploadDirectory}/tmp";
  • 匿名ユーザの「新規アカウント作成」と「ページの編集」はとりあえず無効に
 $wgGroupPermissions['*']['createaccount'] = false;
 $wgGroupPermissions['*']['edit'] = false;

UMIN の既存データの複製

TODO

  • Extensions の選定と設置
    • Youtube 等の動画貼り付け
    • 査読
    • 等々