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

BUILD: Improve the build and development setup #91

Merged
merged 5 commits into from
Sep 1, 2018
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,8 @@ RewriteRule ^(vendor/|composer\.json|composer\.lock) - [F,L,NC]
# node
##
RewriteRule ^(node_modules/|package\.json|package-lock\.json) - [F,L,NC]

##
# dev files
##
RewriteRule ^(dev-router\.php|dev-os\.php) - [F,L,NC]
61 changes: 61 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ScummVM-Web

This project is the main ScummVM website located at: https://www.scummvm.org

## Getting Started

These instructions will get you a copy of the project up and running on your
local machine for development and testing purposes. See deployment for notes
on how to deploy the project on a live system.

### Prerequisites

The ScummVM website relies on several tools to install properly.
Before installing please make sure you have the following installed:

* [Composer](https://getcomposer.org/)
* [Python & pip](https://www.python.org/) (2.7.9+/3.4+)
* [Node.js & npm](https://nodejs.org/)
* [Git](https://git-scm.com/)

### Installing

Clone this repo

```
git clone https://github.com/scummvm/scummvm-web.git
```

Then run

```
composer develop
```

This will run the build scripts and start a web server on port 8000.

Additionally you can either build or run independently using:
```
composer build
composer run
```
respectively.

## Deployment

To deploy changes to the site, simply push the updates to origin/master and
run site-install on the server.

## Contributing

Similar to ScummVM, please use the appropriate project name when contributing:
* **I18N:** Modifications related to translations.
* **CSS:** Changes to stylesheets.
* **TEMPLATES:** Changes to page and component templates.
* **IMAGES:** Site graphics (Icons are excluded).
* **ICONS:** New game and platform Icons. Please see the Wiki for updated
submission guidelines.
* **DATA:** Site data files.
* **BUILD:** Files related to building and developing the site.
* **WEB:** Catch-all for things that don't fit any of the above, or a mix of
multiple components in a single commit.
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
"post-install-cmd": [
"pscss -f compressed ./scss/main.scss > ./css/main.css",
"pscss -f compressed ./scss/pages/_cloud-style.scss > ./css/cloud-style.css"
],
"build": [
"cd site-update;./install.sh;cd .."
],
"run": [
"php -S localhost:8000 dev-router.php & php dev-os.php"
],
"develop": [
"@build",
"@run"
]
}
}
16 changes: 16 additions & 0 deletions dev-os.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
switch (PHP_OS) {
case "Darwin":
exec('open http://localhost:8000');
break;
case "Linux":
exec('xdg-open http://localhost:8000');
break;
case "Windows":
exec('start http://localhost:8000');
break;
default:
exec('xdg-open http://localhost:8000');
break;
}
?>
30 changes: 30 additions & 0 deletions dev-router.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif|css|js|svg)/', basename($_SERVER["REQUEST_URI"]))) {
return false; // serve the requested resource as-is.
} else {
$url = str_replace('index.php', '', strtolower($_SERVER['PHP_SELF']));
$url = trim($url, '/');
$urlArray = explode("/", $url);

$_GET['p'] = $urlArray[0];
switch ($urlArray[0]) {
case "feeds":
$_GET['f'] = $urlArray[1];
break;
case "compatibility":
$_GET['v'] = $urlArray[1];
$_GET['t'] = $urlArray[2];
break;
case "news":
$_GET['d'] = $urlArray[1];
break;
case "screenshots":
$_GET['cat'] = $urlArray[1];
$_GET['game'] = $urlArray[2];
$_GET['num'] = $urlArray[3];
break;
}

}
$_SERVER['SCRIPT_NAME'] = '/index.php';
require 'index.php';
2 changes: 1 addition & 1 deletion include/Objects/QASection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class QASection extends BasicObject {
* @param int $section_number used in the TOC
* @param array $xref reference to xref map
*/
public function QASection($data, $section_number, &$xref) {
public function __construct($data, $section_number, &$xref) {
$this->_title = $data['title'];
$this->_entries = array();
$this->_toc = array();
Expand Down
6 changes: 3 additions & 3 deletions include/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

/* Base URL to the website. */
if ($_SERVER['SERVER_PORT'] == '80') {
$url = "http://{$_SERVER['SERVER_NAME']}" . dirname($_SERVER['PHP_SELF']);
$url = "http://{$_SERVER['SERVER_NAME']}";
} else if ($_SERVER['SERVER_PORT'] == '443') {
$url = "https://{$_SERVER['SERVER_NAME']}" . dirname($_SERVER['PHP_SELF']);
$url = "https://{$_SERVER['SERVER_NAME']}";
} else {
$url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['PHP_SELF']);
$url = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
}

if (substr($url, -1) != '/') {
Expand Down
9 changes: 7 additions & 2 deletions site-update/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ echo '$ git status'
git status

# Generate image sprite
echo 'Generating games and platforms sprites'
echo 'Checking for glue'
if ! [ -x "$(command -v glue)" ]; then
echo 'Installing glue'
pip install glue
fi
echo 'Glue found. Generating games and platforms sprites'
glue images/icons/games/ --img=images/ --scss=scss/sprites/ --retina
glue images/icons/platforms/ --img=images/ --scss=scss/sprites/ --retina
mv scss/sprites/games.scss scss/sprites/_games.scss
Expand All @@ -32,7 +37,7 @@ export COMPOSER_HOME=/var/www/composer
echo "Composer home:" $COMPOSER_HOME
echo '$ composer install'
composer install 2>&1

# Run npm install
echo "$ npm install"
npm install 2>&1
Expand Down