You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a setup so that when I want to deploy ghost to github pages, I just run have to run ghostdeploy in cmd, then git commit -m "some message" and git push. This is the result: https://itsignacioportal.github.io/. No broken links, no broken images, no errors :)
ghostdeploy.bat in a folder that's part of %PATH% //This is the script we launch
python 3.9
replacer3.py //Used mainly to fix links
ImageMagick (Used to resize images, for more performance on github pages)
WSL:
Debian
node v16.14.2 installed via NVM
gssg installed. //gssg doesn't work on Windows with Cygwin, but it does work on WSL, idk why
gssgsummoner.sh at $HOME //A wrapper for gssg
gitcleaner.sh at $HOME //deletes all files except ".git" folder, and my google search console ownership file
/etc/hosts modified to redirect localhost to 192.168.50.21 (beware of the warning on the first line of the file) //modification done because otherwise you would need to have Ghost running directly on WSL, and that's just bothersome for many reasons
The /etc/hosts redirection was made persistant using a scheduled task that runs "with the highest privileges" on user log-in (See: MicrosoftDocs/WSL#418):
@echooffwsl -d Debian -u root ip addr add 192.168.50.11/24 broadcast 192.168.50.255 dev eth0 label eth0:1
netsh interface ip add address "vEthernet (WSL)" 192.168.50.21 255.255.255.0
@echoonexit
You'll obviously have to modify some paths to make this work for you, but hey, it's better than starting at nothing. I spent three days making all of these scripts :p
ghostdeploy.bat:
@echooffREM Summon the Ghost Static Page Generator
wsl.exe -d Debian cd /mnt/c/Users/Sherman/Documents/GitHub/ItsIgnacioPortal.github.io/ ^&^& /home/pinkdev1/gitcleaner.sh ^&^& echo"[+] Running the Ghost Static Site Generator (gssg)..."^&^& /home/pinkdev1/gssgsummoner.sh
REM Fix picture linksecho [+] Fixing picture links and dangling hrefs...
py -3.9 "C:\Program Files\HackingSoftware\ghost\replacer3.py"REM Fix profile pictureecho [+] Fixing profile picture...
cd C:\Users\Sherman\Documents\GitHub\ItsIgnacioPortal.github.io
mkdir content\images\size\w100\2022\03
REM Make sure to modify the Circle-2.png filename to match the actual filename of your uploaded profile picture
magick convert content/images/2022/03/Circle-2.png -resize 100x100! content/images/size/w100/2022/03/Circle-2.png
echo [+] Commiting files...
git config --global core.safecrlf false
git add .
echo [+] The blog is now ready for deployment!
echo [+] Just pick a commit message, and push it to the repo.
cd C:\Users\Sherman\Documents\GitHub\ItsIgnacioPortal.github.io
(file on WSL) gitcleaner.sh
#!/bin/bashshopt -s extglob
cd /mnt/c/Users/Sherman/Documents/GitHub/ItsIgnacioPortal.github.io/
echo"[+] (WSL): Deleting everything except .git folder on \"/mnt/c/Users/Sherman/Documents/GitHub/ItsIgnacioPortal.github.io/\"..."
rm -rf !(.git|googleeef7c96830aeb56d.html)
replacer3.py
importosroot_dir='C:\\Users\\Sherman\\Documents\\GitHub\\ItsIgnacioPortal.github.io'githubPagesDomain="itsignacioportal.github.io"fourLetterAllowedExtensions= ["html"]
threeLetterAllowedExtensions= ["xml", "css", "txt", "xsl"]
twoLetterAllowedExtensions= ["js"]
#There's probably a better way of doing this, but works well enoughdefhasAllowedExtension(file):
iffile[-4:] infourLetterAllowedExtensions:
returnTrueiffile[-3:] inthreeLetterAllowedExtensions:
returnTrueiffile[-2:] intwoLetterAllowedExtensions:
returnTruereturnFalsedefreplaceStrings(searchText, replaceText, file):
print("[+] Replacing \""+searchText+"\" in \""+file+"\" ...")
#https://stackoverflow.com/a/17141572/11490425# Read in the filewithopen(file, 'r') asiofile :
filedata=iofile.read()
# Replace the target stringfiledata=filedata.replace(searchText, replaceText)
# Write the file out againwithopen(file, 'w') asiofile:
iofile.write(filedata)
defreplaceStringsInDir(searchText, replaceText, folder):
forfileinos.listdir(folder):
#print(folder + "\\" + file)ifos.path.isdir(folder+"\\"+file) andfile!=".git":
file=folder+"\\"+fileprint("[+][DEBUG] Recursing to: "+file)
replaceStringsInDir(searchText, replaceText, file)
elifhasAllowedExtension(file):
replaceStrings(searchText, replaceText, folder+"\\"+file)
defreplaceRecursively(searchText, replaceText, mainfolder):
forfileinos.listdir(root_dir):
iffile!=".git":
ifos.path.isdir(mainfolder+file):
replaceStringsInDir(searchText, replaceText, mainfolder+"\\"+file)
else:
replaceStringsInDir(searchText, replaceText, mainfolder)
os.chdir(root_dir)
replaceRecursively("http://localhost:2368", "https://"+githubPagesDomain, root_dir)
#Fix sitemapsreplaceStrings("href=\"//localhost:2368", "href=\"//"+githubPagesDomain, root_dir+"\\"+"sitemap-authors.xml")
replaceStrings("href=\"//localhost:2368", "href=\"//"+githubPagesDomain, root_dir+"\\"+"sitemap-pages.xml")
replaceStrings("href=\"//localhost:2368", "href=\"//"+githubPagesDomain, root_dir+"\\"+"sitemap-posts.xml")
replaceStrings("href=\"//localhost:2368", "href=\"//"+githubPagesDomain, root_dir+"\\"+"sitemap-tags.xml")
replaceStrings("href=\"//localhost:2368", "href=\"//"+githubPagesDomain, root_dir+"\\"+"sitemap.xml")
I've created a setup so that when I want to deploy ghost to github pages, I just run have to run
ghostdeploy
in cmd, thengit commit -m "some message"
andgit push
. This is the result: https://itsignacioportal.github.io/. No broken links, no broken images, no errors :)Environment:
Windows 10
WSL:
The /etc/hosts redirection was made persistant using a scheduled task that runs "with the highest privileges" on user log-in (See: MicrosoftDocs/WSL#418):
You'll obviously have to modify some paths to make this work for you, but hey, it's better than starting at nothing. I spent three days making all of these scripts :p
ghostdeploy.bat:
(file on WSL) gitcleaner.sh
replacer3.py
(file on WSL) gssgsummoner.sh
The text was updated successfully, but these errors were encountered: