0

是否有任何可用于 joomla 2.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-integration-file/src/main/java/org/springframework/integration/file/filters/AbstractFileListFilter.java'} 

通过查看 wp 插件,我想编写自己的 joomla 插件,但 WP 插件使用*wp_remote_fopen*函数,我在 joomla 中没有找到相同类型的函数,并阅读了一些关于使用此类 remote_open 函数的漏洞的文章。这是 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('<', '&lt;', $code);
            self::__setCache($url, $code);
        }

        return $code;
    }  
4

2 回答 2

1

编辑:我已经解决了下面提到的问题并 在 github 上为 Joomla 2.5 和 3.0 发布了一个新插件- 插件作者应该很快更新JED 。


Joomla 2.5有一个Github Repo插件,它使用了@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');
   }

只是JHtml::_('jquery.framework');

根据您的服务器设置,您可能还会看到以下错误firebug

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.

启用跨域请求对我不起作用,所以我通过将repo.js中的所有字体上传到我的网络服务器并编辑repo.js.

于 2015-06-14T17:13:38.013 回答
0

您可能想尝试一下http://darcyclarke.me/dev/repojs/ 我已经设法将它包含在一篇 joomla 文章中(通过直接在页面中包含 javascript 代码),以便可以浏览 github 存储库从 joomla 文章中。

于 2012-07-20T21:59:24.990 回答