2012-05-18 14 views
0

是否有任何插件可用於joomla 2.5從github存儲庫中嵌入代碼。對於新聞媒體來說,有一個插件可以實現同樣的功能(http://wordpress.org/extend/plugins/github-code-viewer-2/)。我想做的事包括從我的github倉庫到使用的東西我的Joomla/K2的文章像Joomla插件將github代碼顯示爲文章

{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; 
    } 
+1

WordPress的wp_remote_fopen方法將等同於在Joomla中使用cURL。看看php.net的信息,瞭解如何使用它。如果cURL在服務器上被禁用,請嘗試使用fopen()或file_get_contents(); – Stilero

+0

我們是否有任何joomla api而不是使用php api? – springpress

+0

不是我所知道的。 JFile類僅用於本地文件。 – Stilero

回答

0

您可能希望有http://darcyclarke.me/dev/repojs/ 試試我已經成功地將其包含在一個Joomla的文章(包括通過在頁面中直接的JavaScript代碼),這樣一方面可以從joomla文章中瀏覽github存儲庫。

1

編輯:我已經固定在下面&published a new plugin on github for Joomla 2.5 & 3.0提到的問題 - 插件作者應該儘快更新JED


有一個Github Repo插件的Joomla 2.5使用由@讓 - 弗爾提到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. 

Enabling Cross Domain Requests沒有爲我工作,所以我通過將repo.js中的所有字體上傳到我的網絡服務器&,修改了repo.js中的4個路徑來修復這些問題。