Forum rules


Before adding a bug or feature request please check it is not already in the bug tracker or answered in the FAQ.



Custom [/youtube] tag for forums.

Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 12:52 am 
User avatar
Desintigrated

Current Scorched3D Rank: Unranked


Joined: Thu Jan 08, 2004 1:32 am
Posts: 2923
Location: Ohio, US
It'd be handy if you could implement support for embedded Youtube vids on the forums.

Handy tutorial on how to do this with phpbb (ironically a youtube vid):

http://www.youtube.com/watch?v=l1G7TJD6Xu0
Image
Scorched 3D: Mountaintop Removal at its finest!
Image


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 8:41 am 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
nice tutorial. you musnt go adding object and embed tags as bb code, though. youd supplant the flash plugin detection ive already coded.

we're very cross-platform. if we're going to embed flash, we need to use an 'swfobject (http://en.wikipedia.org/wiki/SWFObject) style' javascript technique*. (add a placeholder, check for the plugin and append the object to the placeholder if the browser has a flash plugin)

for 2 cents:
i personally dont like youtubes in forums.

feature requests - something id like to see is a strikethrough button for text.


*SWFObject style : / the code i wrote/still use to do the same thing (better, i think) predates SWFObject's first release by about 6 months. bstds : ) here's to recognition.


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 8:57 am 
User avatar
Desintigrated

Current Scorched3D Rank: Unranked


Joined: Thu Jan 08, 2004 1:32 am
Posts: 2923
Location: Ohio, US
Booooo. Stick in the mud.
Image
Scorched 3D: Mountaintop Removal at its finest!
Image


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 9:07 am 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
Deathstryker wrote:
Booooo. Stick in the mud.

it'd be your say more than mine, far as im concerned. i didnt mean to sound like i was ruling it out! it could be done, just slightly differently, but it's not for me to decide.


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 7:25 pm 
User avatar
Desintigrated

Current Scorched3D Rank: Unranked


Joined: Thu Jan 08, 2004 1:32 am
Posts: 2923
Location: Ohio, US
How long will it be before the forum design is changed and therefore will utilize your code for embedding videos?
Image
Scorched 3D: Mountaintop Removal at its finest!
Image


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 7:36 pm 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
i'd planned to finish most of the work on the new site this week. as to when it's implemented, that'll depend on gavin. if we want a smooth swap, we must test everything thoroughly and the time scale on that will probably depend on how many volunteers i can corner.

i dont know if i was clear about my objection to using object/embed for youtubes in forums. the point was less that it would conflict with anything special ive done and more that it's a bad idea for cross platform sites (which is why most people including adobe and youtube themselves where theyre looking for something a bit more robust, do it differently).

i expect the tutorial in the youtube you linked to was only meant to be an example of one way you could do it. i'd be surprised if the phpbb devs saw things differently. so, i wasnt ruling out a [youtube] bb tag . we'd just need to take a little care to do it right. (same would apply on the existing site).

anyway, do you really think it's a good idea? you might end up with a ton of extra nonsense on the forums.


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Tue Mar 16, 2010 8:58 pm 
User avatar
Reduced to ashes

Current Scorched3D Rank: 738






Joined: Mon Mar 27, 2006 3:17 am
Posts: 689
Location: Washington State--
Instead of embedding....um.... could you perma-link to just a YouTube/Scorched3d search? (That way all the videos*(current & future)* from various authors show up when going to the link)?

ie/Re: http://www.youtube.com/results?search_q ... type=&aq=f

Like, a button with the link embedded.

This is kinda cool:(can choose preference)
:arrow: http://www.buttonshut.com/Youtube-Buttons/
Image
"Lead;Follow;or get out of the way"
~Do Not Tread On Me;I may Tread Back~


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Wed Mar 17, 2010 4:47 am 
User avatar
Desintigrated

Current Scorched3D Rank: Unranked


Joined: Thu Jan 08, 2004 1:32 am
Posts: 2923
Location: Ohio, US
Laptops Daddy wrote:
...you might end up with a ton of extra nonsense on the forums.


I'm used to it. Besides, us moderators gotta have SOMETHING to do.
Image
Scorched 3D: Mountaintop Removal at its finest!
Image


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Wed Mar 17, 2010 12:58 pm 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
k. just for fun then/as a hypothetical, what dyou thinks the nicest way to go about it?

we probably dont need to modify any of the phpbb php and template stuff directly. what if we lost those <object><embed> tags and wrote out a container div to append to with some javascript document.write?

i guess the problem would be setting up a unique id for that container div so we can get hold of it later and it doesnt break the markup. (html element id's have to be unique). i spose a plan could be to take the post id from the current page uri and use that as part of the element id? i dont know if youd want to allow for two or more [youtube]s per forum post, so, i guess you could add a random number to each. would that be cool, or is that too hacky?

it wouldnt work for post previews, but the uri for a posted post (eg
Code:
http://www.scorched3d.co.uk/phpBB3/viewtopic.php?f=11&p=59212#p59212
has a nice unique number at the end. shouldnt be a prob to get hold of that in javascript with document.location.href and a regexp or something.


ps:
Deathstryker wrote:
I'm used to it.

touché i guess : )


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Wed Mar 17, 2010 7:26 pm 
User avatar
Desintigrated

Current Scorched3D Rank: Unranked


Joined: Thu Jan 08, 2004 1:32 am
Posts: 2923
Location: Ohio, US
You seem to know miles more about website code than I do so I'll let you be the judge. While I did understand how the tutorial works on the youtube link I posted, it's apparent that you have in mind something much more advanced and farther reaching than my mind can accomplish.
Image
Scorched 3D: Mountaintop Removal at its finest!
Image


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Thu Mar 18, 2010 10:02 am 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
*scans for sarcasm*

yeah, youd be amazed how often i hear that. i probably just wasnt explaining it well.

anyway, this code seems to work quite nicely:
Code:
<script type="text/javascript">
// <![CDATA[

var embedobj = document.createElement("embed");
var attNames = new Array("type","src","width","height","bgcolor");
var attVals = new Array("application/x-shockwave-flash","{TEXT}","400","300","#000000");
var i = 0;
do {
embedobj.setAttribute(attNames[i],attVals[i]); 
i++;
}
while (i < attVals.length);

var txt = document.location.href;
var re = '.*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?((?:[a-z][a-z0-9_]*))';
var p = new RegExp(re,["i"]);

var m = p.exec(txt);
if (m != null)
{
var var1=m[1];
var postId = var1.replace(/</,"&lt;");
var randNo = Math.floor(Math.random()*1001);
var elementId = postId + randNo;

document.write("<div id=\""+elementId+"\"><\/div>");
document.getElementById(elementId).appendChild(embedobj);
}

// ]]>
</script>

if we do it like that, y'see, we can wrap the whole thing in an "if there's a flash plugin" test and we won't have any of this nonsense when people dont have one installed:
Attachment:
nothanks.png
nothanks.png [ 1.71 KiB | Viewed 2062 times ]

(which really isnt fitting on a cross-platform site that means business)

i do feel a bit like we're building a garden in a window box with that, but to me it seems a lot less invasive than modding phpbb's inner workings.


Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Thu Mar 18, 2010 8:26 pm 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
Deathstryker wrote:
Laptops Daddy wrote:
...you might end up with a ton of extra nonsense on the forums.

I'm used to it.

speaking of nonsense...

i was pondering this a bit more, just for fun. extracting the post id from the uri won't help. i was neglecting that each forum post might have a few others above and below it. that regex stuff is pointless.
(im kind of thinking/typing out loud here)

maybe i have a cleaner way to do this anyway. i didnt really like relying on a random number without a check to be sure there were no repeats.

this might work:
Code:
<script type="text/javascript">
// <![CDATA[
var embedobj = document.createElement("embed");
var attNames = new Array("type","src","width","height","bgcolor");
var attVals = new Array("application/x-shockwave-flash","{TEXT1}youtube.com/v/{TEXT2}","400","300","#000000");
var i = 0;
do {
embedobj.setAttribute(attNames[i],attVals[i]); 
i++;
}
while (i < attVals.length);
var elementId = 'youtube' + Math.floor(Math.random()*1001);
if (document.getElementById(elementId) == null) {
document.write("<div id=\""+elementId+"\"><\/div>");
} else {
do
{
elementId = 'youtube' + Math.floor(Math.random()*1001);
document.write("null");
}
while(!(document.getElementById(elementId) == null));
document.write("<div id=\""+elementId+"\"><\/div>");
}
document.getElementById(elementId).appendChild(embedobj);
// ]]>
</script>

it's a little dirty with a loop like that, but there's no way it would hurt unless we had a thousand youtubes on each page. i think id be happy with that code, personally.

wouldnt hurt to have it tested a bit.

*edit. gavin, dont let me loose with that stuff.


Last edited by Laptops Daddy on Mon Mar 21, 2011 7:39 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Custom [/youtube] tag for forums.
PostPosted: Mon Mar 21, 2011 7:45 am 
User avatar
Obliterated

Current Scorched3D Rank: Unranked



Joined: Wed Jun 14, 2006 11:18 pm
Posts: 1480
Location: United Kingdom
thanks spammer. we must finish all that! we have a lovely website. must must get it tied up.

ps:
autotune. it'll make any madonna sound like a tortured cat and vice versa
http://en.wikipedia.org/wiki/Auto-Tune


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group