Codebox Plus

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Anti-Spam Guide
nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Wed Jan 31, 2018 10:57 pm

I solved it this way; in codeboxplus/controller/main.php at the end of the file, just above return $code;, add:

Code: Select all

$code = str_replace("<br/>", "", $code);
Not sure if that's the prettiest way to do it - I don't speak php. :)

The one thing I can't figure out is to make the download function work with multiple CodeBoxes in a single post. When you have 2, the download picks the last one, and if you click the download button for the second one, the link is dead.

User avatar
tlem
Registered User
Posts: 73
Joined: Sun Jan 24, 2016 4:47 pm
Location: France
Name: Thierry
Contact:

Re: Codebox Plus

Post by tlem » Thu Feb 01, 2018 8:35 am

Hi, there is my 2 cents :

For using CodeBox Plus on phpBB 3.2.x forum, I use this version : https://github.com/o0johntam0o/phpBB-Ex ... e/phpbb3.2
And I apply these modification :

For the interline in excess : In \ext\o0johntam0o\codeboxplus\event\main_listener.php
Find

Code: Select all

return $this->codebox_template(preg_replace('#\<br\\s*/?\>#msi', "\n", $arg[3]), $arg[1], $arg[2], $post_id, ++$part);
replace by

Code: Select all

return $this->codebox_template(preg_replace('#\<br\\s*/?\>#msi', "", $arg[3]), $arg[1], $arg[2], $post_id, ++$part);
To remove line numbering : In \ext\o0johntam0o\codeboxplus\event\main_listener.php
Find

Code: Select all

$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
replace by

Code: Select all

//$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
If you want by default a partial extented box : In ext\o0johntam0o\codeboxplus\event\main_listener.php
Find

Code: Select all

$re .= '<div><div style="display: ' . (($lang != 'NULL' && !$this->expanded) ? 'none' : 'inline') . ';">';
replace by

Code: Select all

$re .= '<div><div style="display: ' . (($lang != 'NULL' && !$this->expanded) ? 'none' : 'block') . '; max-height: 250px; overflow:auto;">';
If you want to adapt options of GeSHi : In xt\o0johntam0o\codeboxplus\event\main_listener.php
Find

Code: Select all

// GeSHi
$geshi = new \o0johntam0o\codeboxplus\includes\geshi\geshi();
And change the options from below according to the GeSHi documentation.
If you have problem with "Select All function" : In ext/o0johntam0o/codeboxplus/styles/all/template/script.js
Find

Code: Select all

			s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
replace by

Code: Select all

s.selectAllChildren(e);

I really expect that o0johntam0o will find time to update his extension, and that he adds some setting features.

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Fri Feb 02, 2018 7:13 am

Hi tlem,


Thank you very much for sharing!

Have you found a solution for having multiple CodeBox entries in a single post with a download option?

To demonstrate, consider this example post:

Code: Select all

Codebox example:

[Codebox=lua file=testone.lua]
test1
[/Codebox]

Adding a second codebox example:
[Codebox=lua file=testtwo.lua]
test2
[/Codebox]

In the above post, when I click on the first download link, it downloads testtwo.lua. When clicking on the second download link (for testtwo.lua) I get Information: Code contents not found.

testone.lua can't be downloaded from the post at all.

If you have a solution for this - please share, I'd be delighted!

User avatar
tlem
Registered User
Posts: 73
Joined: Sun Jan 24, 2016 4:47 pm
Location: France
Name: Thierry
Contact:

Re: Codebox Plus

Post by tlem » Fri Feb 02, 2018 7:57 am

Hi nou nou
I do not use the download function, but I think that what you talk about came from script.js.

My knowledge is not sufficient to help you, but maybe someone with more knowledge will help you. Be patient. ^^

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Tue Feb 06, 2018 5:31 pm

Hi tlem,


I'm hoping to find the time to look into it again soon. I think it's in main.php, as that is where the previous download issues were, too. But I'm not sure. As I said before, no knowledge of PHP to speak of...

Basically it creates a separate ID for each instance of Codebox inside a post, but there is only ever one valid link.

Development being picked up again would be terrific. It really is a great and useful extension.

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Fri Feb 09, 2018 2:49 am

The download issue is fixed! Hurray!

Thanks to kasimi, who was so kind to take a look at the code:
  • Open controller/main.php
  • Find

    Code: Select all

    preg_match_all('#<CODEBOX codebox="[a-z0-9_-]+" file=".*"><s>\[Codebox=[a-z0-9_-]+ file=(.*)\]<\/s>(.*?)<e>\[\/Codebox]<\/e><\/CODEBOX>#msi', $post_data['post_text'], $code_data);
  • Replace with

    Code: Select all

    preg_match_all('#<CODEBOX codebox="[a-z0-9_-]+" file=".*?"><s>\[Codebox=[a-z0-9_-]+ file=(.*?)\]<\/s>(.*?)<e>\[\/Codebox]<\/e><\/CODEBOX>#msi', $post_data['post_text'], $code_data);
There are several versions of main.php in circulation, so if the Find string doesn't match, look for

Code: Select all

//- Process post data
// Collect code
Near line 200, and replace the regex underneath.

Thanks again kasimi, and people in this thread! :D

User avatar
tlem
Registered User
Posts: 73
Joined: Sun Jan 24, 2016 4:47 pm
Location: France
Name: Thierry
Contact:

Re: Codebox Plus

Post by tlem » Fri Feb 09, 2018 8:29 am

Thanks to kasimi (and you too nou nou).

sfzeller
Registered User
Posts: 11
Joined: Mon Dec 11, 2017 9:02 pm

Re: Codebox Plus

Post by sfzeller » Tue Mar 20, 2018 7:54 pm

Does anybody know how to modify the syntax highlighter https://github.com/s9e/phpbb-ext-highlighter. E.g., I want the tabs to be at 4 spaces instead of 8 etc.?

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Wed Mar 21, 2018 3:27 am

sfzeller wrote:
Tue Mar 20, 2018 7:54 pm
Does anybody know how to modify the syntax highlighter https://github.com/s9e/phpbb-ext-highlighter. E.g., I want the tabs to be at 4 spaces instead of 8 etc.?
I did that with this bit of css:

Code: Select all

.codebox code {
    white-space: pre;
    tab-size: 4;
    -moz-tab-size: 4;
	-o-tab-size: 4;
}

sfzeller
Registered User
Posts: 11
Joined: Mon Dec 11, 2017 9:02 pm

Re: Codebox Plus

Post by sfzeller » Wed Mar 21, 2018 6:43 pm

Thank for your reply. But the css you posted refers to Codebox only, not the Highlighter I would like to use, right? If not, and it does apply to the phpBB highlighter, then which style sheet would I be modifying and where can I find it? Sorry for my very basic questions.

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Thu Mar 22, 2018 7:16 am

The CSS goes into your style's stylesheets, so it applies to all codeboxes on the forum. The highlighter will highlight the syntax, not change the syntax.

sfzeller
Registered User
Posts: 11
Joined: Mon Dec 11, 2017 9:02 pm

Re: Codebox Plus

Post by sfzeller » Thu Mar 22, 2018 4:15 pm

OK, so I added this to: /styles/prosilver/theme/content.css (the only stylesheet I found that had code styles in it):

.codebox code {
overflow: auto;
display: block;
height: auto;
max-height: 200px;
padding: 5px 3px;
font: 0.9em Monaco, "Andale Mono","Courier New", Courier, monospace;
line-height: 1.3em;
white-space: pre;
tab-size: 4;
-moz-tab-size: 4;
-o-tab-size: 4;
}

but it didn't change anything.

nou nou
Registered User
Posts: 189
Joined: Sat Oct 29, 2016 8:08 pm

Re: Codebox Plus

Post by nou nou » Thu Mar 22, 2018 9:15 pm

Maybe this helps?

viewtopic.php?f=74&t=2254026

The way I figure out CSS is right click on the element I'd like to change, then select "inspect element" and play with all the CSS rules that show up until the thing does what I want. Then roll those changes into a custom CSS file.

sfzeller
Registered User
Posts: 11
Joined: Mon Dec 11, 2017 9:02 pm

Re: Codebox Plus

Post by sfzeller » Mon Mar 26, 2018 4:08 pm

I'm sorry I wasn't very clear in my last post. I have less of a problem inserting the css into the correct stylesheet than applying the style whenever I choose <code> rather than <codebox>. I was under the impression that when I use <code> it would display the code using the highlighter, not codebox. I have both extensions enabled (see attached images) so perhaps they conflict?

Image
Image

Post Reply

Return to “Extension Requests”

Who is online

Users browsing this forum: No registered users and 13 guests

cron