Dream In Code Website Widget

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

33 Replies - 7170 Views - Last Post: 15 August 2011 - 01:35 PM

#1 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Dream In Code Website Widget

Post icon  Posted 12 August 2011 - 03:53 AM

*
POPULAR

This project happened rather spontaneously earlier this evening and I would like to post what it is all about and share it with the dream in code community.
I made a widget for members that would like to post their information onto their website/blog/portfolio/etc. Bragging rights are always fun and it is a good way to promote the dream in code community.
I know that this project was done last summer when the Dream In Code API first came out but I wanted to make my own and make the code available to all of those that wanted to: a, learn and/or b, modify it and make it your own.

Posted Image

If you would like to add it to your website you only need to use the following code with your own user id, which can be found on your profile page's url.

<iframe scrolling="no" style="width: 282px;height: 76px;border: none;"src="http://atomicbucket.com/dreamincode/?id=175017"></iframe>


For more information:
Git Wiki: https://github.com/c...e-User-API/wiki
Git Source: https://github.com/c...n-Code-User-API

Try out your user id: http://atomicbucket....code/?id=175017

Is This A Good Question/Topic? 10
  • +

Replies To: Dream In Code Website Widget

#2 RudiVisser  Icon User is online

  • .. does not guess solutions
  • member icon

Reputation: 1001
  • View blog
  • Posts: 3,556
  • Joined: 05-June 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 04:38 AM

Sweet, I like it.

If I may suggest a few things, in class.UserBar.php, the following:
1; Remove
        //unset the user_nid
        unset($user_nid);


It's really serving no purpose.

2; Change your switch statement at the bottom to group together the common elements, ie. from:
        switch($this->group)
        {
            case 'Expert w/DIC++':
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/expert_group.gif.pagespeed.ce.FoAO90i5Rq.gif';
                break;
            case 'Expert' :
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/expert_group.gif.pagespeed.ce.FoAO90i5Rq.gif';
                break;
            case 'Author' :
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/author_group.gif.pagespeed.ce.mwMUIrHI0a.gif';
                break;
            case 'Author w/DIC++' :
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/author_group.gif.pagespeed.ce.mwMUIrHI0a.gif';
                break;
            case 'Contributors';
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/contributor_group.gif.pagespeed.ce.Qg1-UpavDq.gif';
                break;
            default :
            return "";
                break;
        }


To:
        switch($this->group)
        {
            case 'Expert w/DIC++':
            case 'Expert' :
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/expert_group.gif.pagespeed.ce.FoAO90i5Rq.gif';
                break;
            case 'Author' :
            case 'Author w/DIC++' :
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/author_group.gif.pagespeed.ce.mwMUIrHI0a.gif';
                break;
            case 'Contributors';
                return 'http://cdn2.dreamincode.net/dreamincode/forums/public/style_extra/group_icons/contributor_group.gif.pagespeed.ce.Qg1-UpavDq.gif';
                break;
        }
        return '';


3; Move your HTML out of the class file. You could create a sizetemplates/ folder and have the files in there named usb.phtml, make the size dynamic and simply check if that size exists, if it does, use it, otherwise use usb.phtml as the default and include it in.

This post has been edited by RudiVisser: 12 August 2011 - 04:40 AM

Was This Post Helpful? 0
  • +
  • -

#3 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 04:44 AM

1. Not removing it.
2. I may change up the icons that are displayed ie half and half icon of expert and dic++ so it's going to stay the same way. These values should really be stored inside of constants though.
3. I don't see the need in doing it this way. It'll load into a frame and the content won't be cached. I do plan on keeping the same html for everything, having a base line css and then another on top to work with the different sized.
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is online

  • .. does not guess solutions
  • member icon

Reputation: 1001
  • View blog
  • Posts: 3,556
  • Joined: 05-June 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 05:44 AM

View Postcalebjonasson, on 12 August 2011 - 12:44 PM, said:

1. Not removing it.

Any particular reason?

View Postcalebjonasson, on 12 August 2011 - 12:44 PM, said:

2. I may change up the icons that are displayed ie half and half icon of expert and dic++ so it's going to stay the same way. These values should really be stored inside of constants though.

Fair enough!

View Postcalebjonasson, on 12 August 2011 - 12:44 PM, said:

3. I don't see the need in doing it this way. It'll load into a frame and the content won't be cached. I do plan on keeping the same html for everything, having a base line css and then another on top to work with the different sized.

Put very simply, PHP files should not contain HTML and vice versa (apart from display logic). This is why it is better to do it that way, it will also keep your class down to doing what it's meant to do, actually producing the variables for use.
Was This Post Helpful? 0
  • +
  • -

#5 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 05:50 AM

1. It's already written.
3. There's no need to have multiple files load when I can get away with one. Also with an html file I can't take advantage of compression over the wire like I can with php. It's the only html so there is no harm. Normally splitting is great but on cross site embedding the browser isn't going to store any of the html code.
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is online

  • .. does not guess solutions
  • member icon

Reputation: 1001
  • View blog
  • Posts: 3,556
  • Joined: 05-June 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 06:03 AM

View Postcalebjonasson, on 12 August 2011 - 01:50 PM, said:

1. It's already written.
3. There's no need to have multiple files load when I can get away with one. Also with an html file I can't take advantage of compression over the wire like I can with php. It's the only html so there is no harm. Normally splitting is great but on cross site embedding the browser isn't going to store any of the html code.

?

You don't need to have multiple HTML files, you can simply do include("usb.phtml"); in that method.

There is also no difference between having the HTML in a string or loading it in from a file, of course you can still use compression "over the wire", I don't get what you mean.

Splitting your HTML/PHP is great in all situations not cross site embedding, this is absolutely nothing to do with it and the browser does cache anyway, not that that has anything to do with anything.
Was This Post Helpful? 0
  • +
  • -

#7 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 08:59 AM

Browser only caches the images loaded from dream in code I'm not seeing anything else stored. I don't see why you are pushing to split the little html that is in the php and move it into another file. I understand if this were more than a 1-2 hour project and it consisted of more than 200 lines but the core of this little project is only one file and I would much rather have a 'usbDisplay' function for the html all in one file than put up with php encode and dealing with multiple files.
Was This Post Helpful? 2
  • +
  • -

#8 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1251
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Dream In Code Website Widget

Posted 12 August 2011 - 10:56 AM

This is pretty sweet. Going to place it in my website. :D
Was This Post Helpful? 0
  • +
  • -

#9 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 943
  • View blog
  • Posts: 2,353
  • Joined: 15-February 11

Re: Dream In Code Website Widget

Posted 12 August 2011 - 11:31 AM

Doesn't work with UTF-8(my member title). Haven't looked at your code but I'd suggest applying utf8_decode on the XML string before loading it into SimpleXML.

This post has been edited by codeprada: 12 August 2011 - 11:32 AM

Was This Post Helpful? 0
  • +
  • -

#10 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4314
  • View blog
  • Posts: 7,473
  • Joined: 08-June 10

Re: Dream In Code Website Widget

Posted 12 August 2011 - 11:54 AM

http://atomicbucket....code/?id=391026

This could be because I'm behind a web filter, but this is what shows up for me:

Posted Image

So I'm missing my picture and my title bar.
Was This Post Helpful? 0
  • +
  • -

#11 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 12:03 PM

Currently working on it Curtis, the problem is that your display picture does not end in jpeg and is not given to me in the xml. It is listed as a known problem that I will fix when I get home.

As for the badge not showing up. I can't seem to find a few of the badges such as mentor without bringing in the other badges such as dream in code++. I think that I am just going to have to crop one up unless I can get a hold of skyhawk and he can send me the links that are required.

Known Issues
https://github.com/c...User-API/issues

@codeprada, I'm going to add that to the list of things that I can add to it and it should be fixed for you by tomorrow.
Was This Post Helpful? 0
  • +
  • -

#12 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4314
  • View blog
  • Posts: 7,473
  • Joined: 08-June 10

Re: Dream In Code Website Widget

Posted 12 August 2011 - 12:05 PM

They're a single picture, there's no Mentor badge without DIC++.
Was This Post Helpful? 0
  • +
  • -

#13 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 12:09 PM

View PostCurtis Rutland, on 12 August 2011 - 08:05 PM, said:

They're a single picture, there's no Mentor badge without DIC++.


Then it looks like I'm going to have to do a little croppy-croppy-shoppy-shoppy and make one that will work out with it. I also need to add in 'admin', 'moderator', 'greater', and 'webmaster' (although I have doubts these will get used a whole lot.
Was This Post Helpful? 0
  • +
  • -

#14 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 02:03 PM

Neat idea, very cool, nice work :).
Was This Post Helpful? 0
  • +
  • -

#15 calebjonasson  Icon User is offline

  • $bert = new DragonUnicorn(); $bert->rawr();
  • member icon

Reputation: 207
  • View blog
  • Posts: 988
  • Joined: 28-February 09

Re: Dream In Code Website Widget

Posted 12 August 2011 - 02:28 PM

While this is still alive and active. Is there anything that you guys would like to see from it as far as dimensions, profile vs display icon, etc goes?
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3