Skip to content
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

Titania in GitHub Codespaces #384

Draft
wants to merge 8 commits into
base: 3.3.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Debian version
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# Install PHP
RUN apt-get -y update
RUN apt-get -y install php php-xml php-mbstring php-curl php-zip php-xdebug

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install MySQL
RUN apt-get -y install mysql-server php-mysql

# Xdebug
ADD resources/xdebug.ini /etc/php/8.1/apache2/conf.d/xdebug.ini

# Configure Apache
RUN echo "Listen 8080" >> /etc/apache2/ports.conf && \
a2enmod rewrite
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": { "VARIANT": "ubuntu-22.04" }
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {
// Allow Xdebug to listen to requests from remote (or container)
"remote.localPortHost": "allInterfaces"
},
//"devPort": {},
// Specify which VS Code extensions to install (List of IDs)
"extensions": ["xdebug.php-debug"]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [80, 9003],

// Use 'postCreateCommand' to run commands after the container is created.
"postStartCommand": "bash .devcontainer/resources/setup.sh",

"remoteEnv": {
"PHPBB__CODESPACESX12": "true"
},

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"github-cli": "latest"
}
}
38 changes: 38 additions & 0 deletions .devcontainer/resources/phpbb-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
installer:
admin:
name: admin
password: adminadmin
email: admin@example.org

board:
lang: en
name: My Board
description: My amazing new phpBB board (Titania)

database:
dbms: mysqli
dbhost: 127.0.0.1
dbport: 3306
dbuser: phpbb
dbpasswd: phpbb
dbname: phpbb
table_prefix: phpbb_

email:
enabled: false
smtp_delivery : ~
smtp_host: ~
smtp_port: ~
smtp_auth: ~
smtp_user: ~
smtp_pass: ~

server:
cookie_secure: false
server_protocol: http://
force_server_vars: false
server_name: localhost
server_port: 80
script_path: /

extensions: ['phpbb/titania']
47 changes: 47 additions & 0 deletions .devcontainer/resources/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copy Apache configuration
# sudo rm /etc/apache2/sites-enabled/000-default.conf
# sudo cp .devcontainer/resources/phpbb-apache.conf /etc/apache2/sites-enabled/000-default.conf

# Start MySQL
sudo service mysql start

# Start Apache
sudo service apache2 start

# Add SSH key
echo "$SSH_KEY" > /home/vscode/.ssh/id_rsa && chmod 600 /home/vscode/.ssh/id_rsa

# Create a MySQL user to use
sudo mysql -u root<<EOFMYSQL
CREATE USER 'phpbb'@'localhost' IDENTIFIED BY 'phpbb';
GRANT ALL PRIVILEGES ON *.* TO 'phpbb'@'localhost' WITH GRANT OPTION;
CREATE DATABASE IF NOT EXISTS phpbb;
EOFMYSQL

# Download dependencies
echo "Dependencies"
composer install --no-interaction

# Install phpBB
echo "phpBB project"
composer create-project --no-interaction phpbb/phpbb /workspaces/phpbb

# Copy phpBB config
echo "Copy phpBB config"
sudo cp /workspaces/customisation-db/.devcontainer/resources/phpbb-config.yml /workspaces/phpbb/install/install-config.yml

# https://docs.github.com/en/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace
sudo export PHPBB__CODESPACESX=$CODESPACES

echo "Symlink extension"
sudo rm -rf /var/www/html
sudo ln -s /workspaces/phpbb /var/www/html
sudo mkdir /workspaces/phpbb/ext/phpbb
sudo ln -s /workspaces/customisation-db /workspaces/phpbb/ext/phpbb/titania

echo "phpBB CLI install"
cd /workspaces/phpbb && composer install --no-interaction
sudo php /workspaces/phpbb/install/phpbbcli.php install /workspaces/phpbb/install/install-config.yml
sudo rm -rf /workspaces/phpbb/install

echo "Completed"
13 changes: 13 additions & 0 deletions .devcontainer/resources/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

zend_extension=xdebug.so

[xdebug]
xdebug.mode=develop,debug
xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.log='/var/log/xdebug/xdebug.log'
xdebug.connect_timeout_ms=2000
xdebug.idekey=VSCODE

variables_order = "EGPCS"
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/ext/phpbb/titania": "${workspaceRoot}/"
},
"log": true
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"php.debug.ideKey": "VSCODE"
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,12 @@ If you have a translation please read the information on patches.

You can get involved by reporting bugs in the bug tracker (see below) and providing patches/improvements (see above).

### Codespaces

This project can be run in GitHub Codespaces by following the link under port 80 in the `Ports` tab and then navigating to `/app.php/db` in the browser.

If you run Titania in GitHub Codespaces, make sure to update the server name in ACP -> Server Settings -> Domain Name to match the Codespaces URL. Set the port to 443, copy the server name provided by GitHub automatically when the Codespace is created, and then set `Force server URL settings` to `Yes`.

## Bug Tracker

If you find a bug, please submit it to the [Customisations Database](https://github.com/phpbb/customisation-db/issues) bug tracker.
2 changes: 1 addition & 1 deletion attachment/plupload.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ public function configure_ext(\phpbb\titania\config\config $ext_config, \phpbb\t
'S_PLUPLOAD_EXT' => true,
'FILTERS' => $filters,
'CHUNK_SIZE' => $chunk_size,
'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action),
'S_PLUPLOAD_URL' => str_replace('http', 'https', htmlspecialchars_decode($s_action)), //TODO:fix this
'MAX_ATTACHMENTS' => $max_files,
'ATTACH_ORDER' => ($this->config['display_order']) ? 'asc' : 'desc',
'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files),
4 changes: 4 additions & 0 deletions config/controllers.yml
Original file line number Diff line number Diff line change
@@ -196,6 +196,8 @@ services:
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.subscriptions'
- '@text_formatter.parser'
- '@text_formatter.utils'

phpbb.titania.controller.contrib.revision:
class: phpbb\titania\controller\contribution\revision
@@ -216,6 +218,8 @@ services:
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.subscriptions'
- '@phpbb.titania.message'
- '@text_formatter.parser'
- '@text_formatter.utils'

phpbb.titania.controller.contrib.revision.edit:
class: phpbb\titania\controller\contribution\revision_edit
19 changes: 18 additions & 1 deletion controller/contribution/manage.php
Original file line number Diff line number Diff line change
@@ -37,6 +37,12 @@ class manage extends base
/** @var \phpbb\titania\subscriptions */
protected $subscriptions;

/** @var \phpbb\textformatter\s9e\parser */
protected $parser;

/** @var \phpbb\textformatter\s9e\utils */
protected $utils;

/** @var bool */
protected $is_moderator;

@@ -68,15 +74,19 @@ class manage extends base
* @param \phpbb\titania\attachment\uploader $screenshots
* @param \phpbb\titania\attachment\uploader $colorizeit_sample
* @param \phpbb\titania\subscriptions $subscriptions
* @param \phpbb\textformatter\s9e\parser $parser
* @param \phpbb\textformatter\s9e\utils $utils
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions)
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils)
{
parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access);

$this->message = $message;
$this->screenshots = $screenshots;
$this->colorizeit_sample = $colorizeit_sample;
$this->subscriptions = $subscriptions;
$this->parser = $parser;
$this->utils = $utils;
}

/**
@@ -490,6 +500,9 @@ protected function submit($authors, $old_settings)
// Set custom field values.
$this->contrib->set_custom_fields($this->settings['custom']);

// Parse the contrib name so emojis can be used
$this->contrib->contrib_name = $this->parser->parse($this->contrib->contrib_name);

// Create relations
$this->contrib->put_contrib_in_categories(
$this->settings['categories'],
@@ -708,6 +721,10 @@ protected function assign_vars($error)
$this->contrib->type->id
);
}

// Unparse the contrib name
$this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name);

$this->message->display();
$this->contrib->assign_details();
$this->display->assign_global_vars();
16 changes: 15 additions & 1 deletion controller/contribution/revision.php
Original file line number Diff line number Diff line change
@@ -53,6 +53,12 @@ class revision extends base
/** @var bool */
private $skip_epv = false;

/** @var \phpbb\textformatter\s9e\parser */
protected $parser;

/** @var \phpbb\textformatter\s9e\utils */
protected $utils;

/**
* Constructor
*
@@ -71,15 +77,20 @@ class revision extends base
* @param \phpbb\titania\attachment\uploader $uploader
* @param \phpbb\titania\subscriptions $subscriptions
* @param \phpbb\titania\message\message $message
* @param \phpbb\textformatter\s9e\parser $parser
* @param \phpbb\textformatter\s9e\utils $utils
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message)
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils)
{
parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access);

$this->uploader = $uploader;
$this->subscriptions = $subscriptions;
$this->message = $message;

$this->parser = $parser;
$this->utils = $utils;

// Increase timeout when dealing with revisions
@set_time_limit(90);
}
@@ -217,6 +228,9 @@ public function add($contrib_type, $contrib)
// Load the revisions for this contribution
$this->contrib->get_revisions();

// Unparse the contrib name
$this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name);

if (sizeof($this->contrib->revisions))
{
// Find out what the previous revision was, if this is a new revision to an existing contribution
4 changes: 3 additions & 1 deletion controller/helper.php
Original file line number Diff line number Diff line change
@@ -131,7 +131,9 @@ public function route($route, array $params = array(), $is_amp = true, $session_
{
$route = parent::route($route, $params, $is_amp, $session_id, $reference_type);

return ($this->config->offsetGet('cookie_secure') && strpos($route, 'http://') === 0) ? 'https://' . substr($route, 7) : $route;
$full_route = ($this->config->offsetGet('cookie_secure') && strpos($route, 'http://') === 0) ? 'https://' . substr($route, 7) : $route;

return $this->get_real_url($full_route);
}

/**
2 changes: 1 addition & 1 deletion controller/manage/manage.php
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public function base()
{
if ($page['auth'])
{
redirect($page['url']);
redirect($page['url'], false, true);
}
}

10 changes: 9 additions & 1 deletion controller/manage/queue/item.php
Original file line number Diff line number Diff line change
@@ -85,6 +85,11 @@ public function display_item($id)
return $this->helper->needs_auth();
}

// Create type link information for tags (e.g., make sure the tag hyperlinks back to the type)
$queue_type = $this->types->get($this->queue->queue_type);
$queue_type_name = $queue_type->name;
$queue_type_url = $queue_type->url;

// Display the main queue item
$data = \queue_overlord::display_queue_item($this->id);

@@ -96,11 +101,14 @@ public function display_item($id)

$tag = $this->request->variable('tag', 0);

// Make sure the item category is added to the breadcrumb.
// If the user clicks on a tag (e.g., a tag like "New" or "All")
// then this part ensures it gets added to the navigation breadcrumbs
if ($tag)
{
// Add tag to Breadcrumbs
$this->display->generate_breadcrumbs(array(
$this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag)),
$this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag), [$queue_type_name => $queue_type_url]),
));
}

1 change: 1 addition & 0 deletions controller/manage/queue/queue.php
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ public function display_queue($queue_type)

// Add to Breadcrumbs
$this->display->generate_breadcrumbs(array(
// This is where the type gets displayed
$this->type->lang['lang'] => $this->get_queue_url($this->type->id),
));

Loading