-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f22d48
Showing
9 changed files
with
6,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Styles | ||
The style repository that can be found at brewerwall.com/api/v1/styles. Feel free to fork and use however. If you see a mistake or would like to add any missing styles, submit a pull request with the modifications/additions. | ||
|
||
## Updating Styles | ||
If you would like to update styles, update `styles_master.json`. Once the file has been updated run: | ||
```bash | ||
./generate | ||
``` | ||
|
||
This command will generate a CSV and MYSQL file, along with copying over the master JSON file to another json file. This is merely a bash script that calls a php file, so you must have php available. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"data":"styles" | ||
} |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
php lib/generate_formats.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
//CONFIG | ||
$config = json_decode(file_get_contents("config.json"), true); | ||
|
||
// SCRIPTS VARS | ||
$master_file = $config['data']."_master.json"; | ||
$json = file_get_contents($master_file); | ||
$array = json_decode($json, true); | ||
|
||
// CONVERT MASTER FILE TO CSV | ||
$f_csv = fopen('formats/'.$config['data'].'.csv', 'w'); | ||
|
||
$keys_set = false; | ||
foreach ($array as $line){ | ||
if(!$keys_set){ | ||
fputcsv($f_csv, array_keys($line)); | ||
$keys_set = true; | ||
} | ||
fputcsv($f_csv, $line); | ||
} | ||
|
||
//CONVERT MASTER FILE TO MYSQL INSERT STATEMENTS | ||
$f_mysql = fopen('formats/'.$config['data'].'.mysql', 'w'); | ||
|
||
$keys_set = false; | ||
foreach ($array as $line){ | ||
if(!$keys_set){ | ||
fwrite($f_mysql, "INSERT INTO ".$config['data']." (".implode(',',array_keys($line)).")\nVALUES\n"); | ||
$keys_set = true; | ||
} | ||
|
||
//Wrap strings in quotes. | ||
$line = array_map(function($obj){ | ||
if(!is_numeric($obj)) | ||
return "'".addslashes($obj)."'"; | ||
else | ||
return $obj; | ||
}, $line); | ||
|
||
$insert_values[] = "(".implode(',',$line).")"; | ||
} | ||
fwrite($f_mysql, implode(",\n", $insert_values)); | ||
|
||
// COPY MASTER FILE TO FORMATS | ||
copy($master_file, "formats/".$config['data'].".json"); |
Large diffs are not rendered by default.
Oops, something went wrong.