Giter VIP home page Giter VIP logo

onehourgamejam's Introduction

OneHourGameJam

Source code required to run your very own One hour game jam event.

Content

  • Requirements
  • Installing
  • Common Tasks
  • Migrating to a new server
  • Contributing
  • Overview of site structure, order of operations
  • Glossary of development terms

Requirements

Requires a web server with PHP versions between 5.6 and 8.1 (possibly newer, untested), and MySQL or MariaDB. Requires Mysqli package for PHP.

Installing

You can either install with vagrant or you can manually install (if you want to install on a production server)

With Vagrant:

Prerequisites: npm, composer, git, vagrant

Windows:

sh ./install_dependencies.sh
vagrant up

Linux:

./install_dependencies.sh
vagrant up

You can now find your local version of 1hgj at: http://192.168.48.49

This will setup a scotchbox vagrant box with 1hgj fully installed. You only need to set up the admin user (see below in "First Startup"). You will be able to develop as you would normally.

Manually:

What you need is a web server capable of running PHP, for example Apache.

If you prefer to follow a video tutorial, please watch the following - keep in mind this video hasn't been updated in a while so read through the rest of the written guide where inconsistencies appear between what the video shows and what you see when setting up:

OneHourGameJam Local Copy Setup

1: Install Dependencies

  • Install Node Package Manager (npm):
    • Either install node.js (npm comes with it, though node.js is otherwise not used by this software)
    • Or install npm only:
      • Download the latest version from https://nodejs.org/dist/npm/
      • Unzip
      • Add the file containing npm.cmd into your Path (environment variables)
  • Install Composer: https://getcomposer.org/download/
  • Ensure git can be used via the command line
  • Run ./install_dependencies.sh (on Windows sh ./install_dependencies.sh What this does is:
    • Clones the various dependencies from npm (javascript), composer (php) and git into a temporary "vendor" folder
    • Copies the relevant files from each repository (distributable, minified, etc.) into a "dependencies" folder
    • Deletes the vendor folder
    • Once this process finishes the website is ready for use

2: Download XAMPP

  • Go to Apache and download a version for your operating system (For PHP 5.6, not a VM version)
  • Install (On Windows this must be to C:/XAMPP)

3: Start Server

  • Start XAMPP Control Panel
  • Find Apache and MySQL services in the panel and Start them (If it fails to start, shut down Skype, the two programs conflict)

4: Set up web server content

  • Check out this repository to C://XAMPP/htdocs/onehourgamejam (Windows) or /Applications/XAMPP/htdocs/onehourgamejam (Mac)

5: Install website

  • Go to https://localhost/onehourgamejam/ - this should point you to the install page
  • Enter the following data into the form:
    • Host: localhost
    • Username: root
    • leave Password blank
    • Database Name: onehourgamejam
    • tick "Initialise database"
  • Press "Setup Database"
  • Go to http://localhost/onehourgamejam (A message confirming the database upgrade may appear)

6: Open the site

  • Go to http://localhost/onehourgamejam
  • Create your first user (The first user created will be an administrator)
    • Press "Log in / register" in the menu
    • Enter a username and password
    • Press the "Log in / register" button

Subsequent startups

  • Only the server must be started: See 3: Start Server

Common tasks

First administrator account

The first registered account will have admin rights.

Adding more administrators

Adding or removing administrators can be done via the "Manage users" administrative menu.

Adding jams

Done on the website - can be scheduled for the future in which case the theme is only revealed once the set time passes. An automatic jam scheduler feature also exists, set up in site configuration.

Removing or editing jams and entries and entries

Editing jams and entries can be done via the website's "edit content" menu.

Removing a user

Manually remove them from the database table 'user'

Remotely log out a user or all users

Manually remove the user's entries from the database table 'session'

Migrating to a new server

The site uses a site-wide pepper (for password and session id salting*). This pepper is generated the first time you launch the website, so it's unique for each deployment. It's saved in the config table. Changing this will invalidate all session IDs and passwords. When migrating, it is important to preserve this pepper value and the session password iterations value.

*The site also uses per-user salts, not just the site-wide pepper.

Contributing

You're welcome to contribute to this project whether you know how to code or not.

If you know how to code, please search the issues by technology you know:

Issues found in the Good First Issue label are probably a good place to start. The issues there tend to require less familiarity with how the project works in-depth.

If you don't know how to code, that's okay. You can still offer a lot of value by reading and commenting on Issues, identifying issues which are out of date or no longer relevant, and reporting new issues - either bugs or suggestions.

If you need help, please join us on Discord, the URL to which can be found on https://onehourgamejam.com/

In-depth overview of site structure, order of operations

This section aims to describe how the site functions from a high level, intended for developers who wish to contribute to the site's development.

  • The entry point for every page load (except the API) is through index.php. From there it passes through stages:
    • Site code aggregation (Giving access to all php files which are needed)
      • php/site.php includes all other required php files
      • php/global.php defintes globally accessible variables
      • php/dependencies.php definies which pages exist, a user's required authorization level to access them (guest, user, admin), and which text rendering needs to happen for that page (so we don't render all jams when viewing themes
    • Data retrieval (Data is copied from the database into PHP arrays)
      • php/init.php retrieves almost all data from the database and puts it into "Data" objects (For example $userData = new UserData();, irrespective of if it's needed by the page to be rendered of not
      • php/models.php Each Data object contains a list of Models. Each model corresponds to an entry. For example the UserData data object contains a list called $UserModels of UserModel objects, where each UserModel corresponds to a site user.
    • Site Actions
      • php/actions.php If there is a pending site action (login, game submission, etc.) then we perform it at this stage.
      • php/actions/... The associated actions.php file is loaded and the action is performed (Site actions are configured in php/models/SiteActionModel.php)
      • After the action is performed, the page is redirected to the action's result's redirect URL, as configured in SiteActionModel.php. This page load stops here, and after the redirect happens, the process begins again from the top, this time without a pending site action.
    • Text Rendering
      • php/init.php -> php/dependencies.php Dependencies are retrieved from the list $pageSettings. These determine which bits of the rendered dictionary will be rendered, and to what level of detail (Render Depth). For example the main page needs each jam to also render the games in that jam, so the "main" page defines "RenderJams" => RENDER_DEPTH_JAMS_GAMES,, but the jams list page doesn't need games rendered, so it defines "RenderAllJams" => RENDER_DEPTH_JAMS which means that the games within each jam will not be rendered. The difference between RenderJams and RenderAllJams is not important for this example
      • php/presenter or RenderXYZ() functions All the required text rendering for a page happens next. Data objects, Models and render depth information is supplied as requires. The goal is to move all RenderXYZ() functions (like RenderUsers(..)) to Presenters, like AdminLogPresenter
      • php/page.php RenderPageSpecific(..) Some pages have something special about them, this is handled in a catch-all RenderPageSpecific(..) method.
    • Templates
      • index.php All rendered text can now be found in $dictionary. Some general purpose templates (called partials) are loaded along with the page template to be rendered. The fully rendered page is then printed.
      • template/... These mustache + html template files contain the structure and design of the page. See Mustache documentation for more detail on the {{XYZ}} tags, but they correspond to the structure of the contents of $dictionary, which was rendered into by the Text Rendering step.

Glossary of development terms

  • Global variable - Any variable that's not passed into a function, and is instead accessed with a global $varName at the start of a function - these are being phased out in favor of providing data through function arguments, return values and properly scoped variables. Global variables are defined in php/global.php
  • Dependencies - Settings for a particular page, including the data rendering which is necessary for it to be displayed correctly. Defined in php/dependencies.php
  • Data (Object) - An object which contains multiple models and sometimes related derived data (such as games for each user in addition to a list of all games). Each model in turn corresponds to a data entry - For example a UserModel corresponds to an individual user, while UserData is the representation of all users. These are defined in php/models and created in php/init.php
  • Model - A simple data object, which corresponds to one entry, for example an individual user, an indivual jam, an individual game, etc. These are defined in php/models
  • ViewModel - A simple data object, which is created by a Presenter. ViewModels contain the rendered text used with templates to create the rendered web page. php/viewmodels
  • Database Interface - These objects are intended to abstract away SQL code from the rest of the site. They are used by Data objects to acquire the data they need, and by Site Actions to perform the required modifications the action requires. php/databaseinterfaces
  • Site Actions - Any "write" operation on the site (logging in/out, submitting a game, etc.). When a site action finishes processing the page will redirect to a result page (for example after logging in, it will redirect the user to the site index, unless the login attempt fails, in which case it will redirect to the login page). The redirect is invisible to the user and will restart the page load process. This means modifications only need to be done on the databsae, and not on data objects or models as those will be discarded by the redirect. If a site action results in a message for the user (example "Logged in successfully") this is defined in SiteActionModel, returned in the corresponding site action, stored in a cookie to survive the page reload (the redirect mentioned earlier) and then displayed as part of the page reload. Site Actions are defined in php/models/SiteActionModel.php and stored in php/actions.
  • (Text) Rendering - Most may be used to the term rendering in relation to computer graphics. In this case it refers to converting raw data into the final texts which will be shown on the page. Rendering is performed by a Presenter, defined in php/presenters. The output of rendering are ViewModels, which are gathered into the Dictionary and used (Along with a Template) to create the rendered web page.
  • Presenters - Objects which contain the functions necessary to do text rendering. These take Data objects and Models and output ViewModels. Whether or not they run for a particular page load is determined by Dependencies and Render depth. Presenters are defined in php/presenters
  • Controllers - These correspond to actions the site needs to perform on its own, e.g. automatic jam scheduling, automatic theme pruning, etc. php/controllers
  • Render depth - Not all pages require the same depth to rendering - There is room for optimisation: For example, the Jams page only requires each jam entry is rendered, but the index page requires each rendered jam to also have the games contained within it to be rendered. Render depth usually refers to users, jams and games. Presenters and render functions need to ensure a cycle can't happen. For example a call to RenderUsers() with a render depth of Users and Jams mustn't render for each user which jams they participated in followed by which users participated in those jams followed by which jams those users participated in, etc. Instead it should render a list of users and for each user the jams that user participated in. The jams Render depth for a specific page is defined in dependencies.
  • Page Specific - Some pages require some special processing. This is done in a catch-all RenderPageSpecific() method. It's just a big switch-case statement with a lot of dependencies to data objects. It's a hacky solution and can be improved. This method is defined in php/page.php
  • Dictionary - All rendered text is stored in an array called dictionary. This is passed into mustache, along with partials and the page's template, and contains the texts which will be placed into the template. The dictionary is structured to contain some key-worded sections, most of which correspond to their specific presenter, such as $dictionary["users"] or $dictionary["jams"] and some common ones like "CONFIG" corresponding to the page config, and "page" corresponding to Page Specific content for that page. Currently the dictionary contains some arrays with keys defined as strings, however these are being phased out in favour of more predictable ViewModels. The dictionary is filled in php/init.php
  • Templates - An html file which uses the Mustache format. These need to be rendered by mustache (done in index.php) before it will display correctly in a browser
  • Partials (templates) - A reusable part of the template. See Mustache documentation. For a partial to be loaded for rendering, it must be listed in the setParitals() call in index.php
  • Mustache - A widely used templating solution. See bobthecow/mustache.php for documentation
  • Plugins - A newer architecture which groups all functionality for a given feature into a single unit. Currently only notifications and the admin log exist as plugins.

onehourgamejam's People

Contributors

adamtpowell avatar crazymatt avatar denneledoe avatar iamshivam-dev avatar katuiche avatar kdrnic avatar liambaloh avatar longarmd avatar mikedx avatar mkalam-alami avatar vintprox avatar wetdesertrock avatar winniehell avatar yoris1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

onehourgamejam's Issues

Cake

Is this how to suggest?

Add Titles to Pages

Change the title sent to the browser for each page (main, submit, profiles) for easy identification.

Author Order

On the Author section of the left-hand sidebar, the authors seem to be randomly displayed. This is fine when there aren't very many authors, but after a while, it becomes unnavigable. Perhaps sorting by alphabetical order or number of games made would make it a lot nicer to use.
1hgjsb

Password length limitation

Allow more than 20 chars
since we are not using SQL anyway why limit to 20 chars?
DesertRock and euske seem to agree with this

Database versioning and automatic upgrading

The database structure changes every so often. To make site upgrades easier, an automated system for DB upgrades should probably exist - something which simply updates the database with ALTER, CREATE and DROP statements as needed between versions.

(Low priority feature)

Fix EditEntry()

EditEntry() in php/entries.php still only edits the deprecated jam_N.json file, and not the database.

Fix is to use the Update query from SubmitEntry() in the EditEntry() function too.

The call is made from the editentry page, accessible through "Manage Content" -> "Edit Entry" -> "Save Entry"

Ability to search by theme

In the 1HGJ Search bar, you should be able to search by theme. That is, if you searched for "Deeper and Deeper", the games of 1HGJ 2 should appear.

Better "Download" button indicator

At the moment, it's not clear where to click to download the game, the "tweet", "share on facebook" and "share on google plus" buttons are also bigger than they should be.

img1

and

img2

Asset submission

It'd be nice to have something for submitting assets, maybe like the entry submission page with a link to the asset file & a thumbnail, hosted by the uploader. Some of the good general purpose assets could be hosted onsite, like the ones bitslap shared.

Feature could be admin only or open to all users.

Author links useless unless on home page

The links to each author on the sidebar do not do anything unless the user is on the main page (i.e. "Assets" page). Shouldn't it redirect the user to the main page first?

Split page generation into data acquisition -> processing -> dictionary -> rendering

Split processing into four stages: Data acquisition -> Data processing -> Dictionary -> Rendering

Data acquisition: Fetch all the data we'll need (either entire database or use feature flags to determine what we need)
Data processing: Process the data to get all the values we'll need to show to the user or make the site work properly
Dictionary: Fill the dictionary for rendering with all the content, formatted for output
Rendering: Render with mustache using templates and the dictionary

Use Composer for dependency management

Currently 1hgj only uses Mustache, which is just copy-pasted in the 1hgj source. But we could probably use more libraries or frameworks to make development easier, so getting them through Composer might be a good idea.

Recent participation user ranking

I could use a display of all users' participation in recent jams (what percentage of the last N jams they've participated in). Reason is to find the most active users - to offer site administration to, so 1hgj can continue to run even after I lose interest.

Ability to edit old entries

A possibility to edit old entries would be wonderful. Many of my entries either have lost their screenshot, or it is impossible to download them.

Indicate number of entries

This is a suggestion to indicate the number of jam entries in the header for the jam. Maybe something like:

30th hour game jam, 120 participants 
Theme: Spam Bots
Started: 01 Jan 1870 at 01:00

Use bcrypt

SHA isn't meant for password hashing these days, and while the current way isn't necessarily insecure, bcrypt would surely be better. Suggestion: use PHP's password functions

Create poll system

I'd like to know whether to move from IRC to Discord and whether the day and time the jam is at still works for people, so I'd like to poll them... Changes like that tend to have a short-term negative impact on participation as some members don't move with the community, so I'd like to gauge how big an impact that would have...

Ideally polls could be configured in site configuration.

GET Parameter to hide Livestream

Perhaps we should have a GET parameter so that livestreamers can visit that link, or a "Hide the Stream" button to the link, and the livestream won't automatically start for that user.

Link to Submit Issue

Not everyone knows what to do if they have found a bug in the One Hour Game Jam website. Perhaps we should add a "submit an issue" link somewhere, similar to as shown below, or even at the bottom of the page.
submit1

Rules and assets pages

We need a rules page and an assets page

Rules: Text about stuff.

Assets: Archive for files. Like Art, audio, various templates.

Clock gets out of sync

After a while, the javascript clock in the top right gets out of sync.

Needs to be changed from setTimeout(..,1000) to something based on current vs target time.

Teams

The implementation of teams

Something like on ldjam.com or ludumdare.com:
A user can create a team, then other users can join it and the team can submit a game.

Clean install does not promote first user to admin

As per title, installing OHGJ from github (master / aff3295 ), importing SQL to mysql, configuring DB and running does not give first user access to any admin settings, which have to be set manually in db/user/user_role)

Steps to reproduce:

git clone https://github.com/OneHourGameJam/OneHourGameJam/
cd OneHourGameJam

install DB, load SQL from SQL/1hgj.sql *

edit config/db.php with database info

php -S localhost:8080

open browser to localhost:8080

login/register with any user / pass

see no admin privileges. Schedule no jams.

Next jam date / time incorrect

Future jam date (top right corner) seems to be incorrectly hardcoded, scheduling a jam does not show the correct date and time.

in php/helpers.php, GetNextJamDateAndTime() function sets next_jam_suggested_time to saturday +20 hours.

screenshot from 2016-11-19 10-40-14

Get a SSL certificate

Http is not secure and it people can easily steal information sent over http.
The issue is that people often reuse passwords which means that all non-https password sites are the weakest link.

HTTPS please!

Move session storing to database

Yes, I know, I know. I can hear you judging. But yeah, everything is stored in the database, apart from sessions. At the moment, sessions are stored in data/sessions.json.

Invalid dates for past two jams

Jams 28 and 27 indicate (01 Jan 1970) as the date they occurred. If this is in fact true, we should adopt the slogan Longest running game jam!

Score API

Make a common score API for games to use

/WhoIs => returns logged in user at the requester's IP
/AddScore => Adds a score entry for the user with the requester's IP
/Scores => List of top scores + User's best score

Add automatic announcements over Twitter

Add a way to automatically make announcements over Twitter as the game jam approaches. The idea is for these announcements to happen at predetermined times before and during the jam. So for example: "1hgj starts in 12 hours!", "...6 hours!", "3 hours!", "1 hour!", "The jam is on, the theme is: Theme!", etc.

The trigger to check whether an announcement is to be made would be a user loading the website (so not a timed / cronjob thing). This is because I'd like the website to work on managed web hosting, where you only have access to a CPanel interface or something and can't add cronjobs or timed tasks.

Ideally the solution to this would not come with a massive oauth framework / library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.