Commit e07d9b06 authored by Aral Balkan's avatar Aral Balkan

Remove spotlight section from commands

Progress towards #46
parent be43f73d
......@@ -7,7 +7,6 @@
# Usage: better/edit [drafts/]<trackers/sites>/<domain>
#
# e.g., better/edit trackers/google.com
# better/edit spotlight/newdoma.in
# better/edit drafts/sites/newdoma.in
# etc.
#
......@@ -75,7 +74,7 @@ jsonProperty(){
showUsage(){
echo "\nUsage:\n"
echo " better/edit (<trackers/spotlight>|<drafts/sites>|<drafts/trackers>)/<domain> : edit domain\n"
echo " better/edit (<trackers/sites>|<drafts/sites>|<drafts/trackers>)/<domain> : edit domain\n"
echo "The edit command handles necessary copying from drafts, repository actions,"
echo "and issue tracking prerequisites before opening the requested domain’s entry in your editor.\n"
exit 0
......@@ -130,7 +129,7 @@ ensureIssueExists(){
echo " · Ensuring an issue exists for: ${issueTitle}"
# Get all open issues in the content repository, filter by title, and search for our title.
issue=$(curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/issues\?state\=opened\&labels\=$targetCategory | $private/lib/jq --arg title "$issueTitle" --raw-output '.[] | select(.title == $title)')
issue=$(curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/issues\?state\=opened\&labels\=$category | $private/lib/jq --arg title "$issueTitle" --raw-output '.[] | select(.title == $title)')
if [ -z "$issue" ]; then
# Issue does not exist.
......@@ -147,7 +146,7 @@ ensureIssueExists(){
#
createIssue(){
echo " · Issue does not exist. Creating issue: ‘${issueTitle}’"
issue=$(curl --silent -X POST --header "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/issues --data-urlencode "title=${issueTitle}" --data-urlencode "labels=$targetCategory")
issue=$(curl --silent -X POST --header "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/issues --data-urlencode "title=${issueTitle}" --data-urlencode "labels=$category")
saveIssueIDs
}
......@@ -271,21 +270,21 @@ createBranch(){
#
# Check if the directory already exists in content and, if it doesn’t, copy the draft.
#
local targetFile=~/better.fyi/content/$targetCategory/$domain
local targetFile=~/better.fyi/content/$category/$domain
if [ -d $targetFile ]; then
echo " · Content already exists at ${targetFile}, not copying."
else
#
# Copy, add, commit, and push the newly-added draft and the branch itself to the live repository.
#
echo " · Copying ${domain} from drafts/${category} to content/${targetCategory} in ${branchName}."
cp -R ~/better.fyi/drafts/$category/$domain ~/better.fyi/content/$targetCategory/
echo " · Copying ${domain} from drafts/${category} to content/${category} in ${branchName}."
cp -R ~/better.fyi/drafts/$category/$domain ~/better.fyi/content/$category/
echo " · Adding changes to git."
runIn $contentDirectory "git add --all"
echo " · Committing changes to git."
runIn $contentDirectory "git commit -am \"Added ${domain} draft to ${targetCategory}. Progress towards #${issueIID}.\""
runIn $contentDirectory "git commit -am \"Added ${domain} draft to ${category}. Progress towards #${issueIID}.\""
fi
echo " · Pushing the newly-created branch to the repository at https://source.ind.ie/better/content"
......@@ -299,7 +298,7 @@ openInSystemBrowser(){
#
# TODO: May require a delay for the rebuild to complete.
echo " · Opening the page preview in the system default browser."
open "http://localhost:3000/${targetCategory}/${domain}"
open "http://localhost:3000/${category}/${domain}"
}
......@@ -308,15 +307,15 @@ openInEditor(){
# Open the new draft in an editor if possible.
#
pathToDomainMarkdownFile="~/better.fyi/content/${targetCategory}/${domain}/index.md"
pathToDomainMarkdownFile="~/better.fyi/content/${category}/${domain}/index.md"
if ! [ -z $EDITOR ]; then
# Open in the system default editor.
echo " · Opening the entry for ${domain} (${targetCategory}) in your default editor."
echo " · Opening the entry for ${domain} (${category}) in your default editor."
eval $EDITOR $pathToDomainMarkdownFile
elif hash node 2>/dev/null; then
# Open in sublime text.
echo " · Opening the entry for ${domain} (${targetCategory}) in Sublime Text."
echo " · Opening the entry for ${domain} (${category}) in Sublime Text."
subl $pathToDomainMarkdownFile
else
# Could not open an editor. Tell the person where they can find the new draft.
......@@ -329,14 +328,8 @@ createGlobals(){
contentDirectory=~/better.fyi/content
contentRepositoryID=106
# Draft sites are copied into the spotlight category in content.
targetCategory=$category
if [ $category = 'sites' ]; then
targetCategory='spotlight'
fi
targetCategoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${targetCategory:0:1})${targetCategory:1}"
issueTitle="${targetCategoryCapitalised}: ${domain}"
categoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${category:0:1})${category:1}"
issueTitle="${categoryCapitalised}: ${domain}"
}
......
......@@ -21,7 +21,7 @@ echo """
=====================
dev: start development environment (Better Builder and servers)
edit: edit a domain
edit: edit a site or tracker entry
help: display this help
log-in: sign into source.ind.ie
log-out: sign out of source.ind.ie
......
......@@ -4,10 +4,10 @@
#
# Better command: save
#
# Usage: better/save <trackers/spotlight>/<domain> <message>
# Usage: better/save <trackers/sites>/<domain> <message>
#
# e.g., better/save trackers/google.com "Added a block rule."
# better/save spotlight/somedoma.in "Fixed a typo"
# better/save sites/somedoma.in "Fixed a typo"
# etc.
#
# Saves the your latest changes to the remote Git repository.
......@@ -38,7 +38,7 @@
showUsage(){
echo "\nUsage:\n"
echo " better/save <trackers/spotlight>/<domain> <message>\n"
echo " better/save <trackers/sites>/<domain> <message>\n"
echo "The save command commits your latest changes using the passed message"
echo "and pushes them to the remote branch.\n"
exit 0
......@@ -245,7 +245,7 @@ processOtherArgumentsHook(){
#
processGenericHook(){ tooFewArgumentsError "domain and commit message are missing"; }
processCategoryHook(){
echo "\nError: Please specify a domain in the form: trackers/<domain> or spotlight/<domain>."
echo "\nError: Please specify a domain in the form: trackers/<domain> or sites/<domain>."
showUsage
}
......
......@@ -57,7 +57,7 @@ jsonProperty(){
showUsage(){
echo "\nUsage:\n"
echo " better/stat [<trackers/spotlight|sites>/<domain>]\n"
echo " better/stat [<trackers/sites>/<domain>]\n"
echo "Provides you with general project status or specific status on domain, if specified.\n"
exit 0
}
......@@ -82,14 +82,8 @@ createGlobals(){
draftsDirectory=~/better.fyi/drafts
contentRepositoryID=106
# Special case: spotlight category is populated from domains in drafts/sites; handle the mapping.
targetCategory=$category
if [ targetCategory = 'sites' ]; then
targetCategory='spotlight'
fi
targetCategoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${targetCategory:0:1})${targetCategory:1}"
issueTitle="${targetCategoryCapitalised}: ${domain}"
categoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${category:0:1})${category:1}"
issueTitle="${categoryCapitalised}: ${domain}"
}
......@@ -184,21 +178,9 @@ loginStatus(){
checkLocalExistence(){
local domainWithCategory="${category}/${domain}"
local domainInContent="${contentDirectory}/${domainWithCategory}"
# Special case: spotlight category is populated from domains in drafts/sites; handle the mapping.
if [ $category = 'sites' ]; then
domainInContent="${contentDirectory}/spotlight/${domain}"
fi
local domainInDrafts="${draftsDirectory}/${domainWithCategory}"
# Special case: spotlight category is populated from domains in drafts/sites; handle the mapping.
if [ $category = 'spotlight' ]; then
domainInDrafts="${contentDirectory}/sites/${domain}"
fi
if [ -d "${domainInContent}" ]; then
echo " ✓ Found in content: ${domainInContent}"
else
......@@ -399,7 +381,7 @@ processGenericHook(){
}
processCategoryHook(){
echo "\nError: Please specify a domain in the form: trackers/<domain> or spotlight/<domain>."
echo "\nError: Please specify a domain in the form: trackers/<domain> or sites/<domain>."
showUsage
}
......
......@@ -4,7 +4,7 @@
#
# Better command: submit
#
# Usage: better/submit <trackers/spotlight>/<domain>
# Usage: better/submit <trackers/sites>/<domain>
#
# e.g., better/submit trackers/google.com
# etc.
......@@ -35,7 +35,7 @@
showUsage(){
echo "\nUsage:\n"
echo " better/submit <trackers/spotlight>/<domain> [\"merge message\"] : submit domain for merging\n"
echo " better/submit <trackers/sites>/<domain> [\"merge message\"] : submit domain for merging\n"
echo "Submits your latest saved changes to the remote Git repository and opens a merge request, optionally using the passed merge message.\n"
exit 0
}
......@@ -293,7 +293,7 @@ processOtherArgumentsHook(){
#
processGenericHook(){ tooFewArgumentsError "domain and merge message are missing"; }
processCategoryHook(){
echo "\nError: Please specify a domain in the form: trackers/<domain> or spotlight/<domain>."
echo "\nError: Please specify a domain in the form: trackers/<domain> or sites/<domain>."
showUsage
}
......
#!/bin/sh
#
# Runs command in requested directory and restores the working directory at the end.
# Usage: run <directory> "<command>"
#
runIn(){
pushd $1 >/dev/null
eval $2
popd >/dev/null
}
test(){
echo ">> $@"
echo ">> $#"
}
# main(){
# }
# main
if [ "$#" -eq 1 ] && [ "$1" == "--help" ]; then
showUsageInstructionsHook
exit 0
fi
......@@ -4,10 +4,10 @@
#
# Better command: update
#
# Usage: better/update <trackers/spotlight>/<domain>
# Usage: better/update <trackers/sites>/<domain>
#
# e.g., better/update trackers/google.com
# better/update spotlight/newdoma.in
# better/update sites/newdoma.in
# etc.
#
# Updates your local copy of <domain> with the latest changes of others
......@@ -31,7 +31,7 @@
showUsage(){
echo "\nUsage:\n"
echo " better/update <trackers/spotlight>/<domain> : update domain\n"
echo " better/update <trackers/sites>/<domain> : update domain\n"
echo "Updates your local copy of <domain> with the latest changes of others (if any) from the remote repository.\n"
exit 0
}
......@@ -236,7 +236,7 @@ processGenericHook(){
}
processCategoryHook(){
echo "\nError: Please specify a domain in the form: trackers/<domain> or spotlight/<domain>."
echo "\nError: Please specify a domain in the form: trackers/<domain> or sites/<domain>."
showUsage
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment