Joomla插件将github代码显示到文章中
Joomla2.5是否有任何插件可用于嵌入github存储库中的代码。对于word press,有一个插件可以实现同样的功能(http://wordpress.org/extend/plugins/github-code-viewer-2/). 我想使用类似的方法将github存储库中的代码包含到joomla/k2文章中Joomla插件将github代码显示到文章中,joomla,github,embed,code-view,Joomla,Github,Embed,Code View,Joomla2.5是否有任何插件可用于嵌入github存储库中的代码。对于word press,有一个插件可以实现同样的功能(http://wordpress.org/extend/plugins/github-code-viewer-2/). 我想使用类似的方法将github存储库中的代码包含到joomla/k2文章中 {github url='https://github.com/jamescarr/spring-integration/blob/master/spring-integrat
{github url='https://github.com/jamescarr/spring-integration/blob/master/spring-integration-file/src/main/java/org/springframework/integration/file/filters/AbstractFileListFilter.java'}
通过查看wp插件,我想写我自己的joomla插件,但wp插件使用的是*wp\u remote\u fopen*函数,我在joomla中没有找到相同类型的函数,并阅读了一些关于使用此类远程打开函数的漏洞的文章。以下是WP插件正在做的事情
function getGitHubFile($url, $ttl = null){
self::__loadCache($url, $ttl);
if (isset(self::$cache[$url])) {
$code = self::$cache[$url];
} else {
$code = wp_remote_fopen($url . '?raw=true');
if ($code == '') {
return 'You need cURL installed to use GitHub_Code_Viewer';
}
$code = str_replace('<', '<', $code);
self::__setCache($url, $code);
}
return $code;
}
函数getGitHubFile($url,$ttl=null){
self::uu loadCache($url,$ttl);
if(isset(self::$cache[$url])){
$code=self::$cache[$url];
}否则{
$code=wp\u remote\u fopen($url'.?raw=true');
如果($code=''){
返回“需要安装cURL才能使用GitHub_代码_查看器”;
}
$code=str_replace(“您可能想尝试一下
我已经设法将它包含在joomla文章中(通过在页面中直接包含javascript代码),这样人们就可以从joomla文章中浏览github存储库。编辑:我已经修复了下面提到的问题&-插件作者应该很快就会更新
Joomla 2.5有一个插件,它使用@Jean-Marie Favre提到的
repojs
要在Joomla 3上运行此功能,您需要编辑githubrepo.php
&更改:
if ( version_compare( JVERSION, '3.0', '<' ) == 1) {
if($jquery){
$document->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
}
} else {
JHtml::_('jquery.framework');
}
不适合我,所以我通过将所有字体上传到我的Web服务器并编辑
repo.js
中的4个路径来修复这些问题Wordpress的wp_remote_fopen方法相当于在Joomla中使用cURL。查看php.net以了解如何使用它。如果服务器上禁用了cURL,请尝试使用fopen()或者file_get_contents();我们是否有任何joomla api来代替php api?据我所知,没有。JFile类仅用于本地文件。
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.github.com/darcyclarke/Repo.js/master/fonts/repo.woff.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.github.com/darcyclarke/Repo.js/master/fonts/repo.ttf.