Skip to content

New highlighter #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
!/vendor
/vendor/*
!/vendor/easybook
!/vendor/autoload.php
!/vendor/composer
vendor/
34 changes: 34 additions & 0 deletions acp/pastebin_info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
*
* Pastebin extension for the phpBB Forum Software package.
*
* @copyright (c) 2024 Crizzo <https://www.phpBB.de>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbbde\pastebin\acp;

class pastebin_info
{
function module()
{
return array(
'filename' => '\phpbbde\pastebin\acp\pastebin_info',
'title' => 'ACP_PASTEBIN_TITLE',
'modes' => array(
'pastebin_settings' => array(
'title' => 'ACP_PASTEBIN_SETTINGS',
'auth' => 'ext_phpbbde/pastebin && acl_a_board',
'cat' => array('ACP_PASTEBIN_TITLE')
),
'pastebin_languages' => array(
'title' => 'ACP_PASTEBIN_LANGUAGES',
'auth' => 'ext_phpbbde/pastebin && acl_a_board',
'cat' => array('ACP_PASTEBIN_TITLE')
),
),
);
}
}
24 changes: 24 additions & 0 deletions acp/pastebin_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
*
* Pastebin extension for the phpBB Forum Software package.
*
* @copyright (c) 2024 Crizzo <https://www.phpBB.de>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbbde\pastebin\acp;

/**
* @ignore
*/


/**
* @package acp
*/
class pastebin_module
{

}
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Provides a pastebin including syntax highlighting",
"homepage": "https://www.phpbb.de/community/",
"version": "2.0.7",
"time": "2023-10-03",
"version": "2.1.0-dev",
"time": "2024-04-02",
"license": "GPL-2.0-only",
"authors": [
{
Expand All @@ -21,21 +21,21 @@
}
],
"require": {
"php": ">=7.2, <=8.2",
"easybook/geshi": ">=1.0.8.4"
"php": ">=8.3",
"tempest/highlight": "^1.2"
},
"require-dev": {
"phpbb/epv": "0.0.11"
},
"extra": {
"display-name": "Pastebin",
"soft-require": {
"phpbb/phpbb": ">=3.2.4,<3.4.0@dev"
}
},
"config": {
"phpbb/phpbb": ">=3.3.11,<3.4.0@dev"
},
"config": {
"platform":{
"php":"5.6"
"php":"8.3"
}
}
}
}
64 changes: 34 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified composer.phar
Binary file not shown.
7 changes: 3 additions & 4 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
parameters:
phpbbde.pastebin.path: '%core.root_path%ext/phpbbde/pastebin/'
phpbbde.pastebin.geshi: '%phpbbde.pastebin.path%vendor/easybook/geshi/'
phpbbde.pastebin.geshilangs: '%phpbbde.pastebin.geshi%geshi/'
phpbbde.pastebin.highlight: '%phpbbde.pastebin.path%vendor/tempest/highlight/'
phpbbde.pastebin.hightlightlangs: '%phpbbde.pastebin.highlight%src/Languages/'
phpbbde.pastebin.cron.prune_interval: 86400
tables.phpbbde.pastebin.pastebin: '%core.table_prefix%pastebin'
services:
phpbbde.pastebin.functions.utility:
class: phpbbde\pastebin\functions\utility
arguments:
- '%phpbbde.pastebin.geshilangs%'
- '%core.php_ext%'
- '@language'
- '%phpbbde.pastebin.hightlightlangs%'
phpbbde.pastebin.functions.pastebin:
class: phpbbde\pastebin\functions\pastebin
arguments:
Expand All @@ -35,7 +35,6 @@ services:
- '@phpbbde.pastebin.functions.pastebin'
- '%core.root_path%'
- '%core.php_ext%'
- '%phpbbde.pastebin.geshilangs%'
- '%tables.phpbbde.pastebin.pastebin%'
phpbbde.pastebin.base_listener:
class: phpbbde\pastebin\event\base_events
Expand Down
23 changes: 6 additions & 17 deletions controller/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class main
/** @var \phpbb\captcha\factory */
protected $captcha_factory;

/** @var string */
protected $geshi_lang;

/** @var string */
protected $pastebin_table;

Expand Down Expand Up @@ -105,7 +102,6 @@ public function __construct(
\phpbbde\pastebin\functions\pastebin $pastebin,
$root_path,
$php_ext,
$geshi_lang,
$pastebin_table)
{
$this->auth = $auth;
Expand All @@ -125,7 +121,6 @@ public function __construct(
$this->captcha_factory = $captcha_factory;

$this->pastebin_table = $pastebin_table;
$this->geshi_lang = $geshi_lang;
}

public function handle()
Expand Down Expand Up @@ -294,10 +289,10 @@ private function display_pb()
$error[] = $this->language->lang('PASTEBIN_ERR_NO_TITLE');
}

if (!$this->util->geshi_check($data['snippet_highlight']))
/*if (!$this->util->geshi_check($data['snippet_highlight']))
{
$data['snippet_highlight'] = 'text';
}
}*/

$filedata = $this->request->file('fileupload');

Expand Down Expand Up @@ -415,21 +410,15 @@ private function display_pb()

$highlight = ($this->request->is_set('highlight')) ? $this->request->variable('highlight', '') : $data['snippet_highlight'];

if (!$this->util->geshi_check($highlight))
{
$highlight = 'php';
}

$code = $snippet_text;

$geshi = new \GeSHi($code, $highlight, $this->util->geshi_dir);
$geshi->set_header_type(GESHI_HEADER_NONE);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS, 100);

$code = $geshi->parse_code();
$highlighter = new \Tempest\Highlight\Highlighter();
// TODO: Add option to change language used at this point html,css etc.
$code = $highlighter->parse($code, 'php');

$snippet_text_display = &$code;


$s_hidden_fields = array_merge($s_hidden_fields, array(
's' => $snippet_id,
));
Expand Down
Loading