From f9a6d35d12b895f768beafd826e428e76b16b34a Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Tue, 26 Jun 2018 11:34:14 -0400 Subject: [PATCH 1/2] Bring over w3c-ccg scripts Much more customizeable bash scripts. Thanks @msporny and @kimdhamilton! --- publish.sh.example | 40 -------------- scripts/download-raw-minutes.sh | 83 +++++++++++++++++++++++++++++ scripts/publish.sh | 92 +++++++++++++++++++++++++++++++++ scripts/publishing.cfg.example | 20 +++++++ 4 files changed, 195 insertions(+), 40 deletions(-) delete mode 100644 publish.sh.example create mode 100644 scripts/download-raw-minutes.sh create mode 100644 scripts/publish.sh create mode 100644 scripts/publishing.cfg.example diff --git a/publish.sh.example b/publish.sh.example deleted file mode 100644 index 3e36a69..0000000 --- a/publish.sh.example +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -# -# Generates minutes for the directory given - -echo "Generating minutes and social media posts for $1" -DATESTR=`echo $1 | cut -f2 -d/` -MESSAGE="Add text minutes and audio logs for $DATESTR telecon." - -# Generate minutes -nodejs index.js -d $1 -m -i -git add $1/irc.log $1/index.html $1/audio.ogg -git commit $1/irc.log $1/index.html $1/audio.ogg $1/../index.html -m "$MESSAGE" -git push - -# Generate WordPress and G+ posts -#nodejs index.js -d $1 -w -nodejs index.js -d $1 -g - -# Make sure we want to continue -read -e -p "Check for problems, press 'y' when ready to tweet/email: " -i "n" BROADCAST - -if [ "$BROADCAST" != "y" ] -then - echo "Aborting social media broadcast." - exit -fi - -# Email minutes -nodejs index.js -d $1 -e - -# Tweet telecon results -export SCRAWL_TWITTER_CONSUMER_KEY= -export SCRAWL_TWITTER_SECRET= -export SCRAWL_TWITTER_TOKEN_KEY= -export SCRAWL_TWITTER_TOKEN_SECRET= -export SCRAWL_LINKEDIN_CLIENT_ID= -export SCRAWL_LINKEDIN_CLIENT_SECRET= - -nodejs index.js -d $1 -t - diff --git a/scripts/download-raw-minutes.sh b/scripts/download-raw-minutes.sh new file mode 100644 index 0000000..643d753 --- /dev/null +++ b/scripts/download-raw-minutes.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# +# Fetches the raw minutes for cleanup + +display_usage() { + echo "Downloads raw minutes and audio for CCG group meetings." + echo "" + echo "Usage: ./download-raw-minutes [-lh] [-d date]" + echo " -d [YYYY-MM-DD] pass date argument" + echo " -l launch audio and video editors programmatically" + echo " -h display help" + echo "" + echo "Examples:" + echo "" + echo " ./download-raw-minutes" + echo " downloads raw minutes and audio for the current date" + echo "" + echo " ./download-raw-minutes -d 2018-05-15" + echo " downloads raw minutes and audio for 15 May 2018" +} +AUTO_LAUNCH=false +CREATE_DIRECTORY=true + +for i in "$@" +do +case $i in + --) + display_usage + exit 0 + ;; + -h|--help) + display_usage + exit 0 + ;; + -l|--autolaunch) + AUTO_LAUNCH=true + shift + ;; + -d|--date) + shift + DATE=$1 + break + ;; +esac +done + +# Guess the date if it isn't set +if [ -z "$DATE" ]; then + DATE=`date +%Y-%m-%d` + echo "No date argument supplied; using $DATE" +fi + +echo "....Downloading minutes for date=$DATE" +echo "....Auto launch setting=$AUTO_LAUNCH" + +# Get the editor commands +. ./publishing.cfg + +# Create the minutes directory if it doesn't already exist +mkdir -p $DATE + +# Download raw logs and recordings +echo "....Downloading IRC logs for $DATE..." +curl -# "https://w3c-ccg.s3.digitalbazaar.com/minutes/$DATE-irc.log" > $DATE/irc.log +echo "....Downloading audio recording for $DATE..." +curl -# "https://w3c-ccg.s3.digitalbazaar.com/minutes/$DATE-audio.wav" > $DATE/audio-raw.wav + +echo "Download is finished! To finalize the minutes, clean up the minutes/audio and publish." + +if [ "$AUTO_LAUNCH" = true ]; then + # Edit the IRC log + $EDITOR $DATE/irc.log & + + # Edit the audio recording + $WAV_EDITOR $DATE/audio-raw.wav & +fi + +# Print out directions on finalizing minutes +echo " Instructions for editing minutes and audio:" +echo " https://github.com/w3c-ccg/w3c-ccg.github.io/blob/master/irc_ref.md#edit" +echo " Instructions for publishing:" +echo " https://github.com/w3c-ccg/w3c-ccg.github.io/blob/master/irc_ref.md#publishing" + diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 0000000..8b7bdcc --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Generates minutes for the directory given + +#!/bin/sh +# +# Fetches the raw minutes for cleanup + +display_usage() { + echo "Publish CCG minutes via email and social media." + echo "" + echo "Usage: ./publish [-h] [-d directory]" + echo " -d [/path/to/YYYY-MM-DD] pass directory" + echo " -h display help" + echo "" + echo "Examples:" + echo "" + echo " ./publish -d /path/to/w3c-ccg-meeting/2018-05-15" + echo " previews 2018-05-15 minutes and audio in preview mode (does not broadcast results)" + echo "" +} + +if [ $# -eq 0 ] + then + display_usage + exit 1 +else + for i in "$@" + do + case $i in + --) + display_usage + exit 0 + ;; + -h|--help) + display_usage + exit 0 + ;; + -d|--directory) + shift + DIRECTORY=$1 + break + ;; + esac + done +fi + +echo "....Publishing minutes for directory=$DIRECTORY" + +DATE="$(basename $DIRECTORY)" + +source ../publishing.cfg + +echo "Generating minutes and social media posts for $DATE" +MESSAGE="Add text minutes and audio logs for $DATE telecon." + +# Add default values for missing env vars +if [ -z "$NODE_COMMAND" ]; then + NODE_COMMAND="nodejs" +fi + +if [ -z "$SCRAWL_TO_EMAIL_ADDRESS" ]; then + SCRAWL_TO_EMAIL_ADDRESS="public-credentials@w3.org" +fi + + +# Generate minutes +$NODE_COMMAND index.js -d $DIRECTORY -m -i + +# Make sure we want to continue +read -r -p "Check for problems, press 'y' when ready to commit to git, tweet/email: " BROADCAST + +echo "Broadcast: $BROADCAST" + +if [ "$BROADCAST" != "y" ] +then + echo "Aborting git commit and social media broadcast." + exit +fi + +git add $DIRECTORY/irc.log $DIRECTORY/index.html $DIRECTORY/audio.ogg +git commit $DIRECTORY/irc.log $DIRECTORY/index.html $DIRECTORY/audio.ogg $DIRECTORY/../index.html -m "$MESSAGE" +git push + +# Generate G+ post summary +# $NODE_COMMAND index.js -d $1 -w + +# Email minutes +$NODE_COMMAND index.js -d $DIRECTORY -e + +# Tweet telecon results +$NODE_COMMAND index.js -d $DIRECTORY -t diff --git a/scripts/publishing.cfg.example b/scripts/publishing.cfg.example new file mode 100644 index 0000000..5f71568 --- /dev/null +++ b/scripts/publishing.cfg.example @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Example file for configuration options for publishing minutes + +export EDITOR="/usr/bin/gedit" +export WAV_EDITOR="/usr/bin/audacity" +export NODE_COMMAND="nodejs" + +export SCRAWL_EMAIL_USERNAME= +export SCRAWL_EMAIL_PASSWORD= +export SCRAWL_EMAIL_SERVER= +# Optional port and SSL. Default SSL is false +# export SCRAWL_EMAIL_PORT= +# export SCRAWL_EMAIL_SSL= +export SCRAWL_TWITTER_CONSUMER_KEY= +export SCRAWL_TWITTER_SECRET= +export SCRAWL_TWITTER_TOKEN_KEY= +export SCRAWL_TWITTER_TOKEN_SECRET= +export SCRAWL_LINKEDIN_CLIENT_ID= +export SCRAWL_LINKEDIN_CLIENT_SECRET= From 711b135a158ec3e734f557699297b6d2bcfe9f84 Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Tue, 26 Jun 2018 11:41:30 -0400 Subject: [PATCH 2/2] Update README to explain scripts folder Also make publishing.cfg paths match in scripts --- README.md | 7 +++++++ scripts/publishing.cfg.example => publishing.cfg.example | 0 scripts/download-raw-minutes.sh | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) rename scripts/publishing.cfg.example => publishing.cfg.example (100%) diff --git a/README.md b/README.md index 04b4108..d795dcb 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,13 @@ The WordPress, Google, and Twitter related switches also require some custom environment variables to be setup. For examples of those, see the [publish.sh.example](publish.sh.example). +## Wrapping bash scripts + +If you're on a machine that has bash available, there are a couple useful tools +in the `scripts/` folder. To configure them, copy the `publishing.cfg.example` +to `publishing.cfg`, make your changes, and then run the scripts (which wrap +the node code). + ## Development During development, you'll want to test with the working copy version of diff --git a/scripts/publishing.cfg.example b/publishing.cfg.example similarity index 100% rename from scripts/publishing.cfg.example rename to publishing.cfg.example diff --git a/scripts/download-raw-minutes.sh b/scripts/download-raw-minutes.sh index 643d753..9bc38e9 100644 --- a/scripts/download-raw-minutes.sh +++ b/scripts/download-raw-minutes.sh @@ -54,7 +54,7 @@ echo "....Downloading minutes for date=$DATE" echo "....Auto launch setting=$AUTO_LAUNCH" # Get the editor commands -. ./publishing.cfg +source ../publishing.cfg # Create the minutes directory if it doesn't already exist mkdir -p $DATE