mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
load news from rss
This commit is contained in:
BIN
scm-plugin-backend/src/main/webapp/template/css/images/load.gif
Normal file
BIN
scm-plugin-backend/src/main/webapp/template/css/images/load.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -4,13 +4,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="primary" id="sidebar">
|
<div class="primary" id="sidebar">
|
||||||
<ul class="xoxo">
|
<ul class="xoxo">
|
||||||
<li class="widget-container widget_recent_entries" id="recent-posts-3">
|
<li class="widget-container widget_recent_entries">
|
||||||
<h3 class="widget-title">Latest News</h3>
|
<h3 class="widget-title">Latest News</h3>
|
||||||
<ul>
|
<div id="news"></div>
|
||||||
<li><a title="Bamboo Plugin" href="http://www.scm-manager.org/plugins/bamboo-plugin/">Bamboo Plugin</a></li>
|
<script type="text/javascript">
|
||||||
<li><a title="Jenkins and JIRA Plugin" href="http://www.scm-manager.org/plugins/jenkins-and-jira-plugin/">Jenkins and JIRA Plugin</a></li>
|
$(document).ready(function(){
|
||||||
<li><a title="New Server Part 2" href="http://www.scm-manager.org/server/new-server-part-2/">New Server Part 2</a></li>
|
$('#news').feeds('${contextPath}/news', {
|
||||||
</ul>
|
loadingImage: '${contextPath}/template/css/images/load.gif',
|
||||||
|
maxItems: 5
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</li>
|
</li>
|
||||||
<li class="widget-container widget_links">
|
<li class="widget-container widget_links">
|
||||||
<h3 class="widget-title">Social</h3>
|
<h3 class="widget-title">Social</h3>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" media="all" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" />
|
<link rel="stylesheet" type="text/css" media="all" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" />
|
||||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
|
||||||
|
<script type="text/javascript" src="${contextPath}/template/js/jquery.feed.js"></script>
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="${contextPath}template/js/html5.js"></script>
|
<script src="${contextPath}template/js/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|||||||
114
scm-plugin-backend/src/main/webapp/template/js/jquery.feed.js
Normal file
114
scm-plugin-backend/src/main/webapp/template/js/jquery.feed.js
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/* *
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($){
|
||||||
|
|
||||||
|
$.fn.extend({
|
||||||
|
feeds: function( url, options ){
|
||||||
|
return this.each( function(){
|
||||||
|
new $.feeds(this, url, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$.feeds = function(field, url, options){
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
maxItems: -1,
|
||||||
|
paramName: "url",
|
||||||
|
itemClass: "feeds",
|
||||||
|
errorTitle: "Error",
|
||||||
|
errorMsg: "could not load feeds",
|
||||||
|
loadingImage: null
|
||||||
|
};
|
||||||
|
|
||||||
|
options = $.extend({},defaults, options);
|
||||||
|
|
||||||
|
var $field = $(field);
|
||||||
|
|
||||||
|
loadFeeds();
|
||||||
|
|
||||||
|
function loadFeeds(){
|
||||||
|
loadingView();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
dataType: "xml",
|
||||||
|
success: renderFeeds,
|
||||||
|
failure: renderErrorMsg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderErrorMsg(){
|
||||||
|
$field.append(
|
||||||
|
$("<h3 />").text( options.errorTitle )
|
||||||
|
).append(
|
||||||
|
$("<p />").text( options.errorMsg )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderFeeds(xml){
|
||||||
|
var ul = $('<ul />');
|
||||||
|
$(xml).find('item').each(function(index){
|
||||||
|
if ( options.maxItems <= 0 || index < options.maxItems ){
|
||||||
|
var title = $(this).find('title').text();
|
||||||
|
var link = $(this).find('link').text();
|
||||||
|
ul.append(
|
||||||
|
$('<li />').append(
|
||||||
|
$('<a />').attr('target', '_blank').attr('href', link).text(title)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
clearLoadingView();
|
||||||
|
$field.append(ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadingView(){
|
||||||
|
$field.empty();
|
||||||
|
if ( options.loadingImage != null ){
|
||||||
|
$field.append(
|
||||||
|
$("<div />").addClass("load").append(
|
||||||
|
$("<img />").attr("src", options.loadingImage)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearLoadingView(){
|
||||||
|
$field.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})(jQuery);
|
||||||
Reference in New Issue
Block a user