Project Y

Crazy dog writing code for fun

Resting fully…

April29

I know I’ve been gone for a while but you know me I either bite you all the times or nap my life away. So now that I’m fully rested I figured why not messing with RestFul Services and WordPress. So I started on this plugin called WP Services using PureMVC. All you have to do is this on any page in the blog just add “wp-services/” right after the domain and you should get the xml output of that page. So for example http://www.projecty.org/category/bites/ will become http://www.projecty.org/wp-services/category/bites/ … Do you get it? Also a few extra urls are http://www.projecty.org/wp-services/pages/ , http://www.projecty.org/wp-services/categories/, http://www.projecty.org/wp-services/tags/, http://www.projecty.org/wp-services/archives/ , http://www.projecty.org/wp-services/structure/ . K i’ll keep working on it would be cool to login, register and all of that as well I think.

Peace and have fun

Zo in the house!!!

posted under Bites | No Comments »

Proxy is not working…..

September17

Damn i hate when those proxy don’t work do you? So I guess peeps like doggy style code and are trying to use the FeedMe Rss Reader. Since there are some proxy issues this is the code of the one I use:


K now what about sending me some bones, toys doggie stuff.

Taking a nap now l8z!!!

posted under Bites | No Comments »

FeedMe – RSS reader

September11

[ad]
K so this is the code for that FeedMe Class:

FeedMe.js

var FeedMe = new Class({
    Implements : [Options, Events],
    options : {
        template : '
#link##title#
#desc#
', container : 'FeedMeContainer' }, initialize : function(options) { this.setOptions(options) }, eat : function(url) { this.fireEvent('start'); new Request({ url : url, onSuccess : this._eat.bind(this), onFailure : function(response) {this.fireEvent('failure', response)}.bind(this), onException : function(headerName, error) {this.fireEvent('exception', [headerName, error])}.bind(this) }).send(); }, _eat : function(responseText, responseXml) { this.fireEvent('success', responseXml); //console.log(responseText+' '+responseXml) //try { this._digest(responseXml); }, _digest : function(responseXml) { this.fireEvent('processing'); this.channel = new FeedMe.Channel(responseXml); this.outputContainer = $(this.options.container); ["title","link","description","pubDate","copyright"].each(function(item) { //console.log('chan-'+item); this.outputContainer.getElement('.chan-'+item).set('html',this.channel.get(item)); }.bind(this)); var img = '', image = this.channel.image, src = image.get('src'); if (src != null) { var title = image.get('description'); img = ''+title+''; } this.outputContainer.getElement('.chan-image-link').set('html', img); this.itemsHtml = ''; this.channel.items.each(function(item) { this.itemsHtml += this.options.template.replace( '#link#', ' ').replace( '#title#', '
'+item.get('title')+'
').replace( '#desc#', '
'+item.get('description')+'
') }.bind(this)); this.outputContainer.getElement('.chan-items').set('html', this.itemsHtml); this.fireEvent('done'); } }); FeedMe.Node = new Class({ initialize : function(element) { this.element = element; }, get : function(prop) { if (this.element) { if (prop != 'value') return this.element.get(prop); else this.element.childNodes[0].nodeValue; } return null; } }); FeedMe.BaseItem = new Class({ get : function(prop) { var elm = this.element.getElement(prop); if (elm != null) return elm.childNodes[0].nodeValue; return ''; } }); FeedMe.Item = new Class({ Extends : FeedMe.BaseItem, initialize : function(element) { this.element = element; this.category = new FeedMe.Node(this.element.getElement('category')); this.enclosure = new FeedMe.Node(this.element.getElement('enclosure')); this.guid = new FeedMe.Node(this.element.getElement('guid')); this.source = new FeedMe.Node(this.element.getElement('source')); } }); FeedMe.Channel = new Class({ Extends : FeedMe.BaseItem, initialize : function(xmlDoc) { this.xmlDoc = xmlDoc; this.element = this.xmlDoc.getElement('channel'); this.items = new Array(); this.xmlDoc.getElements('item').each(function(item) { this.items.push(new FeedMe.Item(item)); }, this); this.category = new FeedMe.Node(this.element.getElement('category')); this.image = new FeedMe.Node(this.element.getElement('image')); } });

mootools.ext.js just a quick extension for show and hide functionality

Element.implement({
	visible: function() {
    	return this.style.display != 'none';
  	},
	toggle: function() {
		if (this.visible())this.hide();
		else this.show();
		return this;
	},
	hide: function() {
		this.style.display = 'none';
		return this;
	},
	show: function() {
		this.style.display = '';
		return this;
	},
	smoothScrollTo: function(options){
		var options = $extend({},options||{elementOffset:0});
		try {
			var scrollY = (window.pageYOffset)?window.pageYOffset:document.documentElement.scrollTop;
			if ((!options.minPageOffset && !options.maxPageOffset) ||
			(options.minPageOffset && scrollY > options.minPageOffset) ||
			(options.maxPageOffset && scrollY < options.maxPageOffset))
			if (!__globalSmoothScroll) __globalSmoothScroll = new Fx.Scroll(window);
			__globalSmoothScroll.toElement(this);

		} catch(e) {Logger.log('smoothScrollTo: '+e.message);}
		return this;
	}
});

Test html file:

<html>
	<head>
		<title>FeedMe</title>
		<script src="/js/mootools.core.js" type="text/javascript"></script>
		<script src="/js/mootools.more.js" type="text/javascript"></script>
		<script src="/js/mootools.ext.js" type="text/javascript"></script>
		<script src="/js/feedme.js" type="text/javascript"></script>
		<link rel="stylesheet" href="/css/layout.css" />
		<script type="text/javascript">
		var feedMe = null;
		window.addEvent('domready', function() {
			feedMe = new FeedMe().addEvents({
				start : function() {showStatus('fetching..', 'start');$('FeedMeContainer').hide();},
				success : showStatus.pass('eating..','success'),
				processing : showStatus.pass('digesting..','processing'),
				done : function() {showStatus('dropping kids..','done');showResult.delay(1000);}
			});
			$('sendit').addEvent('click', function() {
				var url = $('rssurl').value;
				if (url == '' || !/http/.test(url)) {
					alert('come on foo!');
					return;
				}
				feedMe.eat("/bites/proxy.php?mimetype=text/xml&url="+encodeURIComponent(url));
			})
		});
		function showStatus(msg, className) {return $('feedingStatus').set('html',msg).set('class', className).show();}
		function showResult(){
			$('FeedMeContainer').show();
			$('feedingStatus').hide();
		};
		</script>
		</head>
	<body>
	<div class="container">
	<input type="text" value="http://news.google.com/news?ned=us&hl=en&q=dog&output=rss" id="rssurl" /> <input type="button" id="sendit" value="Feed Me!!"/>
	<div id="feedingStatus"></div>
	<div id="FeedMeContainer" class="rss" style="display:none;">
		<div id="chan-title"></div>
		<div id="chan-link"></div>
		<div id="chan-description"></div>
		<a href="javascript:void(0);" id="chan-image-link"></a>
		<div id="chan-items"></div>
		<div id="chan-pubDate"></div>
		<div id="chan-copyright"></div>
	</div>
	</div>
	</body>
</html>

You will need a proxy to run outside script within your website or you’ll run into cross-domain issues

Damn I gotta go run with the Boss now I hate when he does that to me.

Later fools!

posted under Bites | No Comments »

Feed Me Feed Me!!!

September10

[ad#200x200]

So I was reading this post at Mootools User Group and i was also kind of hungry. So after a few bites and a quick nap I crancked some code to help this dude from Brazil out. I hope he sends me a bone man!

I think this should do it.

Title: FeedMe
Description: Rss reader

Do you like it? I will put the code up shortly for now look it up with FF or Firebug or hack it damn it.
Gotta go for my walk now Boss is home :)

Peace out!

ps: the code is here now

posted under Bites | No Comments »

Does the code hilite work?

September9

this is gonna be some php code ready fools?


and this should be javascript

ProcessButton= new Class({

	Extends : Widget.Button,

	initialize : function(element, click, options) {

		this.parent(element, click);

		this.options = $extend({

			ready : 'btn.add',

			processing : 'btn.close',

			done : 'btn.done'

		},options);

		this._setText(ProcessButton.States.ready);

	},

	setState : function(state, text) {

		this._setText(state, text);

	},

	_setText : function(state, text) {

		this.state = state;

		if (text) this.options[this.state] = text;

		this.setText(this.options[this.state].localize());

	},

	click : function() {

		if (this.state == ProcessButton.States.done) return;

		var states = ProcessButton.States;

		this._setText(states[((this.state == states.ready)?'processing':'ready')]);

		this.clickAction(this);

	},

	done : function() {

		this._setText(ProcessButton.States.done);

		this.select();

	}

});
posted under Bites | No Comments »