Commit 382e7e6f authored by Aral Balkan's avatar Aral Balkan

Updated the edit command to add exception for category mapping for spotlight...

Updated the edit command to add exception for category mapping for spotlight section (sites → spotlight).
parent a54c08c5
Pipeline #596 skipped
......@@ -8,6 +8,7 @@
#
# e.g., better/edit trackers/google.com
# better/edit drafts/sites/newdoma.in
# better/edit drafts/spotlight/newdoma.in
# etc.
#
# Handles all prerequisites for editing a domain’s entry, including:
......@@ -129,7 +130,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\=$category | $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\=$targetCategory | $private/lib/jq --arg title "$issueTitle" --raw-output '.[] | select(.title == $title)')
if [ -z "$issue" ]; then
# Issue does not exist.
......@@ -146,7 +147,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=$category")
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")
saveIssueIDs
}
......@@ -270,21 +271,21 @@ createBranch(){
#
# Check if the directory already exists in content and, if it doesn’t, copy the draft.
#
local targetFile=~/better.fyi/content/$category/$domain
local targetFile=~/better.fyi/content/$targetCategory/$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/${category} in ${branchName}."
cp -R ~/better.fyi/drafts/$category/$domain ~/better.fyi/content/$category/
echo " · Copying ${domain} from drafts/${category} to content/${targetCategory} in ${branchName}."
cp -R ~/better.fyi/drafts/$category/$domain ~/better.fyi/content/$targetCategory/
echo " · Adding changes to git."
runIn $contentDirectory "git add --all"
echo " · Committing changes to git."
runIn $contentDirectory "git commit -am \"Added ${domain} draft to ${category}. Progress towards #${issueIID}.\""
runIn $contentDirectory "git commit -am \"Added ${domain} draft to ${targetCategory}. Progress towards #${issueIID}.\""
fi
echo " · Pushing the newly-created branch to the repository at https://source.ind.ie/better/content"
......@@ -298,7 +299,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/${category}/${domain}"
open "http://localhost:3000/${targetCategory}/${domain}"
}
......@@ -307,15 +308,15 @@ openInEditor(){
# Open the new draft in an editor if possible.
#
pathToDomainMarkdownFile="~/better.fyi/content/${category}/${domain}/index.md"
pathToDomainMarkdownFile="~/better.fyi/content/${targetCategory}/${domain}/index.md"
if ! [ -z $EDITOR ]; then
# Open in the system default editor.
echo " · Opening the entry for ${domain} in your default editor."
echo " · Opening the entry for ${domain} (${targetCategory}) in your default editor."
eval $EDITOR $pathToDomainMarkdownFile
elif hash node 2>/dev/null; then
# Open in sublime text.
echo " · Opening the entry for ${domain} in Sublime Text."
echo " · Opening the entry for ${domain} (${targetCategory}) in Sublime Text."
subl $pathToDomainMarkdownFile
else
# Could not open an editor. Tell the person where they can find the new draft.
......@@ -327,8 +328,15 @@ openInEditor(){
createGlobals(){
contentDirectory=~/better.fyi/content
contentRepositoryID=106
categoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${category:0:1})${category:1}"
issueTitle="${categoryCapitalised}: ${domain}"
# 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}"
}
......
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