探索,發現,愛好、學習,記錄,分享。
學海無涯,天涯若比鄰,三人行,必有我師。

Xiuno Hook 机制

Xiuno BBS 的插件机制分为两种,一种是 Hook,一种是 Overwrite。所谓 Hook,就是往代码里插入代码,多个插件的代码合并后插入到 hook 指定的位置,最后生成的代码存放于 tmp 目录,被 include

在”Hello, Xiuno Plugin“章节中的实例就是基于 Hook 的。

文件 view/htm/header.inc.htm 中的代码,包含一个 hook header_body_start.htm,我们来将代码插入到此处:

... <body> <!--{hook header_body_start.htm}--> <div id="wrapper"> ... 

制作插件 A:

plugin/
	my_plugin_a/
    	conf.json hook/
        	header_body_start.htm 

假定 header_body_start.htm 的内容为:

Hello, Pugin A 

有插件 B:

plugin/
	my_plugin_B/
    	conf.json hook/
        	header_body_start.htm 

假定 header_body_start.htm 的内容为:

Hello, Pugin B 

那么最后生成的文件位置在 tmp/view_htm_header_body_start.htm,内容为:

...
<body>

Hello, Pugin A
Hello, Pugin B

<div id="wrapper"> ...

因为程序在 include 时候做了转换:

include _include('./view/htm/header.inc.htm'); // 基本等价于: include ''./tmp/view_htm_header_body_start.htm;
版權聲明:本文采用知識共享 署名4.0國際許可協議 [BY-NC-SA] 進行授權
轉載事宜:如需轉載需徵得應允,轉載必須注明來源於本站的信息。
文章名称:《Xiuno Hook 机制》
文章链接:https://www.thefreesky.com/blog/25856.html
本站資源僅供個人學習交流,請於下載後24小時內刪除,不允許用於商業用途,否則法律問題自行承擔。

評論 抢沙发