gs's People
gs's Issues
Migrate from TinySong API to the GrooveShark API for searching
Migrate from TinySong API to the GrooveShark API for searching.
Move classes that do not pertain to an API out of api/
See title.
Personally I use lib/
Update config.php to reflect new changes
Update config.php to reflect new changes, including storing database parameters and update GS password comment to note that passwords should no longer be in MD5 format.
Update Play page to be interactive - Phase 1
Update the play page to be interactive.
Phase 1:
Queue on player page
Volume adjustable from player page.
Class variable used that does not exist
$this->dbh does not exist (and shouldn't)
This issue found in multiple classes: Player, Queue, User, and Song
$this->dbh = $this->db->prepare("SELECT id, token, status FROM queue WHERE status='queued' OR status='playing' ORDER BY status ASC, priority ASC, position ASC LIMIT 2");
$this->dbh->execute();
$rows = $this->dbh->fetchAll(PDO::FETCH_ASSOC);
This would be better written as
$stmt = $this->db->prepare("SELECT id, token, status FROM queue WHERE status='queued' OR status='playing' ORDER BY status ASC, priority ASC, position ASC LIMIT 2");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
Add phpunit config
unittests/phpunit.xml
<phpunit bootstrap="_path_to_autoloader_">
<whitelist>
<directory suffix=".php">./</directory>
</whitelist>
<logging>
<log type="coverage-clover" target="/tmp/coverage.xml"/>
<log type="coverage-html" target="_path_to_coverage_reports_"/>
</logging>
</phpunit>
Rewrite player javascript
Rewrite player.js to be more like global.js
Username is initially required twice
Fix issue with cookie when setting username, causing you to put in the username twice.
Include config.php less
require('config.php');
Add a public variable called config in Base then load your config in.
public function __construct()
{
require('config.php');
$this->config = $config;
When this is done, remove any include config.php found in a class that extends Base and update to use $this->config
Bonus points for converting config.php to anything but a php file (yaml) This class may help you with parsing yaml and can be installed via composer.
Update username page to new UI
Username page was not updated to new UI
Add/Promote icons on mobile are off
Add unit tests
Unit test the following files:
api/gsAPI.php
api/gsControl.php
Create a getter and setter for gsAPI
This should be in the Base class. The getter would handle the code below that is required to handle authentication, and the setter would store the class in to a private variable made for this class (like the template class)
This way you can use getGsAPI when the class is needed.
Some sample code:
function getGsAPI() {
if (!$this->gsapi) {
$this->gsapi = new gsAPI($config['api']['key'], $config['api']['secret']);
// init more of the class here
}
return $this->gsapi
}
function setGsAPI($gsapi) {
$this->gsapi = $gsapi;
}
This will help you later on if you have to write a unittest and mock out gsAPI. The setGsAPI() method would be used in your test to set a mock version of gsAPI.
Rename gs class
I would recommend using Base or something that more defines what that class does.
Break out gsControl into multiple classes
Break out gsControl.php into multiple classes:
Classes:
Song
Queue
User
Song should be a song object that holds data about a new song or a currently queued song (if given an ID).
Queue should process queue specific requests, including returning queued songs, and adding a song to the queue.
User should store user information, including name and available promotions.
Remove $db globals
Create autoload.php
An autoloader will help stop you from requiring every class file that you need. This is done by placing classes in a specific folder and keeping naming consistent.
This is a sample of what I use. You may have to make changes to where classes are stored and how they are named.
<?php
// Extra files that have to be included
include dirname(__FILE__) . '/vendor/autoload.php';
include dirname(__FILE__) . '/config.php';
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\'))
{
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$loaded = false;
$class_file = dirname(__FILE__) . '/lib/classes/' . $fileName;
if (file_exists($class_file))
{
require $class_file;
}
else
{
throw new Exception('Unable to load class: ' . $class_file);
}
}
spl_autoload_register('autoload');
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.