Forum [code] tags

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Forum [code] tags

Post by slavik262 »

A lot of people use

Code: Select all

 tags to post code to the forum.  While doing this makes it really easy to share code with other people, it really disrupts the flow of threads as you have to scroll through dozens of lines of code just to see the next post.

Would it be possible to make text encapsulated in [code] tags fit in a fixed size frame with scroll bars?  That way code can easily be viewed and copied without disrupting the flow of forum threads.
MarcusD
Posts: 16
Joined: Sat Nov 27, 2010 12:57 pm
Location: South Yorkshire, UK

Post by MarcusD »

It is a simple enough mod to change a

Code: Select all

 section to <textarea> however, it would probably be better to have a profile option that allows folding of the [code] sections to be turned on and off, so to anyone with folding turned on sees a "Display Code" link in place of the block.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I see at least no option for that in the admin panel. Then again I never liked forums using code with scrollbars but actually prefer the style here, so I'm not so unhappy about not finding that option...

Having a feature to fold away sections would certainly be nice, but I also don't know about that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Hey, did you guys forgot that I am webdev and phpBB is on GNU license? :D

This is what I coded:
http://testy.kazymjir.org/code_phpbb_irrlicht/demo.html


And here is patchs needed to apply:

# phpBB2/templates/bbcode.tpl

Code: Select all

--- bbcode_old.tpl	2005-12-30 11:38:19.000000000 +0100
+++ bbcode.tpl	2011-02-02 05:00:01.000000000 +0100
@@ -26,9 +26,11 @@
 <span class="postbody"><!-- END quote_close -->
 
 <!-- BEGIN code_open --></span>
-<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
-<tr> 
-	  <td><span class="genmed"><b>{L_CODE}:</b></span></td>
+
+<table class="expandTable" width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr class="expandTable-Button"> 
+	  <td class="code">
+<b>[click to expand/hide code]</b></td>
 	</tr>
 	<tr>
 	  <td class="code"><!-- END code_open -->
# phpBB2/templates/viewtopic_body.tpl

Code: Select all

--- viewtopic_body_old.tpl	2005-12-30 11:38:19.000000000 +0100
+++ viewtopic_body.tpl	2011-02-02 04:57:26.000000000 +0100
@@ -1,4 +1,15 @@
-
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+<script type="text/javascript">  
+$(document).ready(function(){
+    
+    $(".expandTable tr:not(.expandTable-Button)").hide();
+    $(".expandTable tr:first-child").show();
+    
+    $(".expandTable tr.expandTable-Button").click(function(){
+        $(this).next("tr").toggle();
+    });
+});
+</script> 
 <table width="100%" cellspacing="2" cellpadding="2" border="0">
   <tr> 
 	<td align="left" valign="bottom" colspan="2"><a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a><br />
here you can download files:
http://testy.kazymjir.org/code_phpbb_irrlicht/patch/

I've tested it on phpBB-2.0.19, but I don't think those files will differ too much in other 2.0.x versions


PS:
I am not sure that I generated these patch files correctly,
used command "diff -up old new > new.patch",
correct me if I made something wrong, never created patch files before :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Definitely useful. Don't know if it is still necessary, though, since bitplane is actively working on updating schemes for changing to phpbb3. But maybe he can simply throw this code in quickly. Thanks anyway. Maybe we will ask you for some other add-on after the update :wink:
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Ok, just let me know if something is needed to do :)
Post Reply