Skip to content

Instantly share code, notes, and snippets.

@tarnacious
Created November 29, 2011 04:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarnacious/1403462 to your computer and use it in GitHub Desktop.
Save tarnacious/1403462 to your computer and use it in GitHub Desktop.
More good times with Umbraco
// Good times with Umbraco. This time with the broken link checker plug-in (http://our.umbraco.org/projects/developer-tools/broken-link-checker)
// To be fair I think these problems are mainly due to changes in Umbraco > 4.0.
//
// I wouldn't recommend using the plugin, but I had to put in this hacky fix it for a client who wanted to use it.
//
// Firstly it tries to download some javascript from here:
// http://localhost:50812/umbraco/~/umbraco/plugins/FergusonMoriyama/DashRss/dashrss.js
//
// When the location of the file is:
// http://localhost:50812/umbraco/plugins/FergusonMoriyama/DashRss/dashrss.js
//
// I don't know where that script tag gets created, inside the plugin dll? Anyway a 404 in the back office is acceptable in this situation.
//
// So I take the contents of that file and add it directly in the .ascx file which appears to be used for the admin panels the plugin creates.
// I updated the script to ensure it would be ok if ran twice (and it will, because the plugin creates two panels) and it only created one
// global variable (sigh).
//
// Here is the updated DashRss.ascx, to use it unpack the plugin zip file and update DashRss.ascx with this and the plugin will at least do
// what it originally did before version 4.1 or whatever.
//
// Also I think this guy may have fixed it, but I'm not sure.
// http://our.umbraco.org/projects/developer-tools/broken-link-checker/feature-suggestions/13277-version-problem
//
// And I'm not sure if these people ever did..
// http://our.umbraco.org/projects/developer-tools/broken-link-checker/bug-reports/6785-can't-get-any-link-to-show-up-in-the-list
// http://our.umbraco.org/projects/developer-tools/broken-link-checker/bug-reports/10015-Broken-Link-Checker-not-displaying-any-results
//
// In the mean time I will try and work out what I'm doing with my life, it wasn't meant to be like this.
//
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DashRss.ascx.cs" Inherits="FergusonMoriyama.DashRss.DashRss" %>
<script>
// Don't do anything if fmDashRss alread exists
if (!fmDashRss) {
var fmDashRss = {};
// Wrap the rest of the in a function to avoid var leaking into the global scope
(function() {
fmDashRss.refreshInterval = 20; //seconds
fmDashRss.appVPath = '/plugins/FergusonMoriyama/DashRss';
fmDashRss.css = false;
var f = window.document;
var head = f.getElementsByTagName('head')[0];
fmDashRss.renderFeed = function(id, umbracoPath) {
if(!fmDashRss.css) {
fmDashRss.css = true;
var script = f.createElement("link");
script.setAttribute("rel", "stylesheet");
script.setAttribute("type", "text/css");
script.setAttribute("href", umbracoPath + fmDashRss.appVPath + '/dashrss.css');
head.appendChild(script);
}
if(!fmDashRss.loadingGif) {
fmDashRss.loadingGif = umbracoPath + fmDashRss.appVPath + '/ajax-loader.gif';
fmDashRss.loadingGif = '<img src="'+fmDashRss.loadingGif+'" alt="Loading" width="16" height="16"/>';
}
var containerId = $('#'+id).parent().parent().attr('id');
containerId = containerId.replace(/^(.*?\_tab\d{2}).*$/, "$1");
var tabName = $('#' + containerId + ' span nobr').html();
fmDashRss.load(id, tabName, umbracoPath);
}
fmDashRss.load = function(elementId, feedId, umbracoPath) {
$('#'+ elementId).prepend('<p class="loading">Loading ' + fmDashRss.loadingGif + '</p>');
var tsTimeStamp= new Date().getTime();
$.get(umbracoPath + fmDashRss.appVPath + '/RssProxy.aspx', { feed: escape(feedId), time: tsTimeStamp },
function(data){
$('#'+ elementId + ' p.loading').fadeOut('slow', function() {
$('#'+ elementId + ' p.loading').remove();
$('#'+ elementId).html(data);
setTimeout("fmDashRss.load('" + elementId + "', '" + feedId + "', '" +umbracoPath +"')", fmDashRss.refreshInterval * 1000);
});
}
)
}
})();
}
</script>
<div id="<%= this.UniqueID.Replace("$", "_") %>" class="dashRss">
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.tabpagecontainer div:first').each(function() {
$(this).css({'display': 'block'});
});
fmDashRss.renderFeed('<%= this.UniqueID.Replace("$", "_") %>', '/umbraco');
});
</script>
@kakauandme
Copy link

works like charm. Thank's for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment