-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- use 'script' directory to mirror script-to-rule-them-all elsewhere - shortcut for css updating - create-superuser script for use in development envs - shortcut for changing cookie-domain in codespaces
- Loading branch information
Showing
7 changed files
with
181 additions
and
20 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
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,18 @@ | ||
#!/bin/bash | ||
|
||
# This script is used to set the cookie domain when in codespaces | ||
# rather than localhost, this will be something like ajparsons-fluffy-umbrella-wqwwwg9w7q3g694-80.preview.app.github.dev | ||
# we can get the first bit from the CODESPACE_NAME environment variable | ||
|
||
# if we're not in a codespace, then we don't need to do anything | ||
if [ -z "$CODESPACES" ]; then | ||
echo "Not in a codespace, skipping cookie domain setting" | ||
exit 0 | ||
fi | ||
|
||
CODESPACE_URL="$CODESPACE_NAME.preview.app.github.dev" | ||
|
||
# we need to modify conf/general - where it currently says "localhost" we need to replace it with the above | ||
sed -i "s/(\"COOKIEDOMAIN\", 'localhost')/(\"COOKIEDOMAIN\", 'github.dev')/g" conf/general | ||
|
||
echo "Cookie domain set to github.dev" |
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,117 @@ | ||
#!/usr/bin/php | ||
|
||
<?php | ||
|
||
// create-superuser.php | ||
|
||
// This script creates a superuser account in the database. | ||
// It is intended to be be used to create a test superuser in dev | ||
|
||
// Running the file will prompt for a username and password | ||
// or these can be passed in with -u and -p arguments. | ||
|
||
include_once dirname(__FILE__) . "/../www/includes/easyparliament/init.php"; | ||
|
||
// Parse command line arguments | ||
$options = getopt("u:p:"); | ||
|
||
// Check if username and password were passed | ||
if (isset($options["u"]) && isset($options["p"])) { | ||
$email = $options["u"]; | ||
$password = $options["p"]; | ||
// if username isn't set, prompt for it | ||
} | ||
if (!isset($options["u"])) { | ||
echo "Enter username (email address): "; | ||
$email = trim(fgets(STDIN)); | ||
// if password isn't set, prompt for it | ||
} | ||
|
||
if (!isset($options["p"])) { | ||
echo "Enter password: "; | ||
system("stty -echo"); | ||
$password = trim(fgets(STDIN)); | ||
system("stty echo"); | ||
} | ||
|
||
$details = [ | ||
"firstname" => "Test Admin", | ||
"lastname" => "User", | ||
"email" => $email, | ||
"postcode" => "N13 4BS", | ||
"url" => "https://mysociety.org", | ||
"password" => $password, | ||
"optin" => 1, | ||
"status" => "Administrator", | ||
"confirmed" => 1, | ||
]; | ||
|
||
$registrationtime = gmdate("YmdHis"); | ||
$passwordforDB = password_hash($details["password"], PASSWORD_BCRYPT); | ||
|
||
# get database connection | ||
$db = new ParlDB(); | ||
|
||
$q = $db->query( | ||
"INSERT INTO users ( | ||
firstname, | ||
lastname, | ||
email, | ||
postcode, | ||
url, | ||
password, | ||
optin, | ||
status, | ||
registrationtime, | ||
registrationip, | ||
facebook_id, | ||
deleted, | ||
confirmed | ||
) VALUES ( | ||
:firstname, | ||
:lastname, | ||
:email, | ||
:postcode, | ||
:url, | ||
:password, | ||
:optin, | ||
:status, | ||
:registrationtime, | ||
:registrationip, | ||
:facebook_id, | ||
'0', | ||
:confirmed | ||
) | ||
", | ||
[ | ||
":firstname" => $details["firstname"], | ||
":lastname" => $details["lastname"], | ||
":email" => $details["email"], | ||
":postcode" => $details["postcode"], | ||
":url" => $details["url"], | ||
":password" => $passwordforDB, | ||
":optin" => $details["optin"], | ||
":status" => $details["status"], | ||
":registrationtime" => $registrationtime, | ||
":facebook_id" => "", | ||
":registrationip" => "127.0.0.1", | ||
":confirmed" => $details["confirmed"], | ||
] | ||
); | ||
|
||
$q = $db->query("select * from users"); | ||
|
||
if ($q->success()) { | ||
echo "\nUser created: Use the following details to log in:\n"; | ||
echo "Username: "; | ||
echo $details["email"]; | ||
echo "\n"; | ||
echo "Password: "; | ||
echo $details["password"]; | ||
echo "\n"; | ||
} else { | ||
echo "Error creating user"; | ||
} | ||
|
||
|
||
?> |
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,4 @@ | ||
#!/bin/bash | ||
|
||
cd www/docs/style | ||
bundle exec compass watch |
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
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
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