Skip to content

Instantly share code, notes, and snippets.

@codaamok
Created July 12, 2020 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codaamok/b0c1f6b203de03c18ed91268c31520b4 to your computer and use it in GitHub Desktop.
Save codaamok/b0c1f6b203de03c18ed91268c31520b4 to your computer and use it in GitHub Desktop.
PSSouthampton streaming content
<html>
<head>
<style>
/* Background styling */
body {
background-color: #a8c8e0;
font-family: 'Fira Code', monospace;
margin: 0;
}
marquee {
position: absolute;
padding: 50px;
bottom: 95px;
background-color: white;
font-size: 4em;
font-weight: light;
}
img.Chibi {
position: absolute;
left: -5%;
height: 100%;
}
/* Session title styling */
span.sessionTitle {
font-size: 130px;
color: white;
position: absolute;
top: 10%;
left: 30%;
width: 69%;
-webkit-text-stroke: 1px black;
border: 0px solid black;
}
/* Speaker styling */
table.speaker, table.speaker th, table.speaker td {
border: 0px solid black;
}
table.speaker {
text-align: right;
color: white;
position: absolute;
bottom: 275px;
right: 20px;
}
table.speaker td.speakerName {
vertical-align: bottom;
}
span.speakerName {
font-family: Arial, Helvetica, sans-serif;
padding: 0;
height: 60%;
font-size: 75px;
vertical-align: bottom;
}
table.speaker td.speakerTwitterHandle {
vertical-align: top;
}
span.speakerTwitterHandle {
padding: 0;
height: 40%;
font-size: 30px;
vertical-align: middle;
}
span.speakerTwitterHandle img {
vertical-align: middle;
}
img.speakerAvatar {
width: 200px;
margin: 20px;
border-radius: 50%;
border: 7px solid white;
}
/* Social styling */
table.social {
position: absolute;
bottom: 15px;
right: 375px;
width: 200px;
font-size: 25px;
font-weight: light;
color: white;
}
table.social td {
padding: 5px;
}
table.social td.icons {
text-align: right;
}
table.social td.icons img {
width: 50px;
}
</style>
</head>
<body>
<?php
$strJsonFileContents = file_get_contents("properties.json");
$array = json_decode($strJsonFileContents, true);
?>
<marquee behavior="scroll" direction="left" scrollamount="20">
<?php
if (empty($_GET)) {
echo "Use 'message' query string parameter to set message here";
} else {
echo $_GET["message"];
}
?>
</marquee>
<img class="Chibi" src=".\Chibi_Avatar.png"/>
<span class="sessionTitle"><?php echo $array["SessionTitle"];?></span>
<table class="speaker">
<tr>
<td class="speakerName">
<span class="speakerName"><?php echo $array["SpeakerName"];?></span>
</td>
<td rowspan="2">
<?php
echo '<img class="speakerAvatar" src="' . $array["TwitterPicture"] . '"/>';
?>
</td>
</tr>
<tr>
<td class="speakerTwitterHandle">
<span class="speakerTwitterHandle"><img src=".\twitter.png"/ width="50px"> @<?php echo $array["TwitterHandle"];?></span>
</td>
</tr>
</table>
<table class="social">
<tr>
<td class="icons">
<img src=".\twitter.png"/>
</td>
<td>
@PSSouthampton
</td>
<td>
|
</td>
<td class="icons">
<img src=".\internet.png"/>
</td>
<td>
pssouth.co.uk
</td>
</tr>
</table>
</body>
</html>
<#
.SYNOPSIS
Create a new properties.json file containing the speaker's name, session title, Twitter handle and local path to their Twitter profile picture. This script also downloads said profile picture. The produced properties.json file is intended to be consumed by index.php within this gist.
.EXAMPLE
PS C:\> .\New-PSSouthamptonVirtualSession.ps1 -SessionTitle "Some session title goes here" -SpeakerName "Adam Cook" -TwitterHandle "codaamok"
Downloads the profile picture of Twitter account @codaamok to "C:\xampp\htdocs\PSSouthampton"
Creates properties.json file with the below object:
PS C:\> Get-Content -Path "C:\xampp\htdocs\PSSouthampton\properties.json"
{
"SpeakerName": "Adam Cook",
"SessionTitle": "Some session title goes here",
"TwitterHandle": "codaamok",
"TwitterPicture": "speaker.jpeg"
}
.NOTES
Author: Adam Cook (@codaamok)
#>
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SessionTitle,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SpeakerName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$TwitterHandle,
[Parameter()]
[ValidateNotNullOrEmpty()]
[String]$WebRoot = "C:\xampp\htdocs\PSSouthampton",
[Parameter()]
[ValidateNotNullOrEmpty()]
[Switch]$NoApache
)
if (-not (Test-Path "$WebRoot\index.php")) {
Write-Error -Message ("Can not find '{0}', it's possible the sym link does not exist. Consider creating it." -f $WebRoot) -ErrorAction "Stop"
# e.g. mklink /d C:\xampp\htdocs\PSSouthampton "C:\Users\acc\OneDrive - Adam Cook\Documents\Professional\PSSouthampton\streaming"
}
Import-Module "PSTwitterApi" -ErrorAction "Stop"
$Twitter_ConsumerKeys = Get-Secure "Twitter-ConsumerKeys"
$Twitter_AccessKeys = Get-Secure "Twitter-AccessKeys"
$OAuthSettings = @{
ApiKey = $Twitter_ConsumerKeys.UserName
ApiSecret = $Twitter_ConsumerKeys.GetNetworkCredential().Password
AccessToken = $Twitter_AccessKeys.UserName
AccessTokenSecret = $Twitter_AccessKeys.GetNetworkCredential().Password
}
Set-TwitterOAuthSettings @OAuthSettings
$TwitterUser = Get-TwitterUsers_Lookup -screen_name $TwitterHandle -ErrorAction "Stop"
if ($null -eq $TwitterUser -or $TwitterUser.count -eq 0) {
Write-Error -Message ("Could not find twitter user '{0}'" -f $TwitterHandle)
}
else {
$Url = $TwitterUser.profile_image_url -replace "_normal\.", "."
$FileExt = [System.IO.Path]::GetExtension($Url)
$TwitterPictureFileName = "speaker{0}" -f $FileExt
Invoke-WebRequest -Uri $Url -OutFile $WebRoot\$TwitterPictureFileName
}
[PSCustomObject]@{
SpeakerName = $SpeakerName
SessionTitle = $SessionTitle
TwitterHandle = $TwitterHandle
TwitterPicture = $TwitterPictureFileName
} | ConvertTo-Json | Set-Content -Path ".\properties.json" -Force
if (-not $NoApache.IsPresent) {
if (Get-Process -Name "httpd") {
Write-Warning "httpd already running"
}
else {
Start-Process -FilePath "C:\xampp\apache\bin\httpd.exe"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment