vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   BB Code Enhancements - Better code syntax highlighting (https://vborg.vbsupport.ru/showthread.php?t=285933)

Sarteck 07-24-2012 10:00 PM

Better code syntax highlighting
 
1 Attachment(s)
This Modification is meant more as an example than an actual modification, but will work fine as is.

vBulletin by default has three "code" BB Codes.

The [CODE] tag simply gives us monospaced text.

The [HTML] and [PHP] tags give us some highlighted code that's highlighted pretty much how our webserver software decides how to highlight it. For "serious" coding, that's often insufficient.

GeSHi provides much more accurate highlighting and in a vast number of different languages. It's relatively simple to add these languages to your own BB Codes for highlighting, too.

Attached is the latest version of the GeSHi files, 1.0.8.10. You may go to their website at any time and download newer releases, though the latest was released well over a year ago. (I had to repackage it as a ZIP file, because vB.org doesn't accept tar.gz files.)

Download and extract this file. Upload the geshi.php file and the geshi folder to your FORUMROOT/includes folder.

Download the XML product file and Import it as you would a regular Product through your Admin Control Panel. It will install a plugin that contains BB Code functions for the following languages:
  • PHP (as [PHPS])
  • JavaScript (as [JSS])
  • CSS (as [CSSS])
  • SQL (as [SQLS])
  • C++ (as [CPPS])
  • HTML (as [HTMLS])
  • Java (as [JAVAS])
  • Tcl (as [TCLS])
  • BASH (as [BASHS])
(If you're wondering, the "S" stands for "Source".)

By looking through those examples, you can see how to easily add other languages GeSHi handles as well (Lua for some of you game programmers, for example).



This has really helped me communicate code stuff withmy Admins for our forum a lot better than the default vBulletin stuff, and it's nice to have for the coders at my forum as well.



Updated (25.JUL.12) [0.02a]
Included install and uninstall scripts that INSERT or DELETE the above BB Codes to/from your database. WARNING! If you have a BB Code named the same as one of the above that you do NOT want deleted, this product will delete that BB Code from the database if you use the Uninstall script. Just wanted to make that clear.

Updated (01.AUG.12) [0.03a]
Product was previously Disabled by default AND (even after enabling product) the Plugin was disabled. Both are now enabled by default.

Updated (01.AUG.12) [0.04a]
Fixed an error from 0.03a that gave SQL errors when trying to update the product. >_>

Sarteck 07-25-2012 09:21 AM

I'd also request that the Staff here consider using GeSHi for making stuff all prettified. X3 It's obviously not a necessity, but it'd be nice to have code highlighting for SQL, CSS, and JavaScript at least.

Sarteck 07-25-2012 11:06 AM

Updated to include Install/Uninstall scripts that will add (or delete) the BB Codes automatically for you. Now all you need to do is upload the files and import the XML.

ryohnosuke 08-01-2012 06:46 AM

it's working? I'm only getting:

{PlaceHolder}

Saludos.

Sarteck 08-01-2012 09:05 AM

The product was previously disabled by default, and even after enabling the Product, the Plugin was disabled by default.

Both are now enabled by default in v0.03a, so you can download and over-write to fix, or you can simply enable both the Product and then Plugin.

My bad, oops. ^^;

ryohnosuke 08-01-2012 03:50 PM

I uninstalled it and when I want to install your fixed version:

Code:

Database error in vBulletin 4.2.0:

Invalid SQL:
INSERT INTO `vB_bbcode` (`bbcodetag`, `bbcodereplacement`, `bbcodeexample`, `bbcodeexplanation`, `twoparams`, `title`, `buttonimage`, `options`) VALUES
('PHPS', '{Place Holder}', '[PHPS]/** Sample **/ echo "Hello Shitty World";[/PHPS]', 'HIghlights PHP with the Geshi highlighter.', 0, 'PHP v2', '', 1),
('JSS', '{Place Holder}', '[jss]alert(''blah''+"\\n"+bleh);[/jss]', 'JavaScript Syntax Highlight', 0, 'JavaScript Source', '', 1),
('CSSS', '{Place Holder}', '[csss].thisclass {font-size:13px;}[/csss]', 'CSS Source Syntax Highlighting', 0, 'CSS Source', '', 1),
('CPPS', '{Place Holder}', '[CPPS]cout << "Enter number: ";[/CPPS]', 'Highlights C++ with the Geshi highlighter.', 0, 'C++ Source', '', 1),
('HTMLS', '{Placeholder}', '[HTMLS]<html><head><title>Bleh</title></head><body>Blah</body></html>[/HTMLS]', 'Highlights HTML Source with the GeSHi Highlighter.', 0, 'HTML Source', '', 1),
('JAVAS', '{PlaceHolder}', '[JAVAS]/*JavaCode*/[/JAVAS]', 'Highlights Java with the GeSHi highlighter.', 0, 'Java Source', '', 1),
('SQLS', '{PlaceHolder}', '[SQLS]insert into mytable (field1,field2) VALUES (1,4);[/SQLS]', 'Highlights MySQL with the GeSHi highlighter.', 0, 'MySQL Source', '', 1),
('TCLS', '{PlaceHolder}', '[TCLS]set token [http::geturl "http://www.clubbleach.org/forums/bwbots.php" -query $querystring][/TCLS]', 'Highlights Tcl with the GeSHi highlighter.', 0, 'Tcl Source', '', 1),
('BASHS', '{PlaceHolder}', '[BASHS]woogypid=`ps $(cat /usr/lib/eggdrop/pid.Woogy) | grep $(cat /usr/lib/eggdrop/pid.Woogy) 2> /dev/null | awk ''{print $1}''`[/BASHS]', 'For BASH environment syntax highlighting.', 0, 'BASH code', '', 1);;

MySQL Error  : Duplicate entry 'PHPS-0' for key 'uniquetag'
Error Number  : 1062
Request Date  : Wednesday, August 1st 2012 @ 11:48:40 AM
Error Date    : Wednesday, August 1st 2012 @ 11:48:40 AM
Script        : http://www.ryohnosuke.com/foros/admincp/plugin.php?do=productimport
Referrer      : http://www.ryohnosuke.com/foros/admincp/plugin.php?do=productadd
IP Address    : *********
Username      : ********
Classname    : vB_Database_MySQLi
MySQL Version : 5.1.63-cll


Sarteck 08-01-2012 07:48 PM

Sorry, man. My bad for including install code where not necessary. (Thought I needed one for each version, apparently I only need it for the earliest version.)

Everything fixed in 0.04a.

Or... hopefully. XD That's what the "a" is there for, after all.

Sarteck 08-01-2012 07:49 PM

Also, En Taro Adun.

ryohnosuke 08-01-2012 08:02 PM

Ok it works! : D, how can I set up the number lines?

Saludos.

Sarteck 08-02-2012 02:07 AM

There's a line,

//$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);// (Disabled Line Numbers)

Uncomment that.


All times are GMT. The time now is 11:10 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02588 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete