Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Last active June 21, 2017 05:27
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pirafrank/e0db410304d6543a78bdf713b1f5c118 to your computer and use it in GitHub Desktop.
Pythonista script to replace custom domain urls with site.baseurl in jekyll posts.
#! python2
#
# Pythonista script to replace custom domain urls with site.baseurl in jekyll posts.
# Usage: from a text editor app, share text to this script. It will return 'jekyllfied'
# text in another share popup. See it in action:
#
# @Author
# Francesco Pira (dev at fpira dot com)
#
import sys
import appex
import console
import dialogs
# write here your domain
stable_url = 'https://fpira.com'
test_url = 'http://test.fpira.com'
# the actual script
if not appex.is_running_extension():
console.hud_alert("Error: This script only runs as extension",'error',3)
sys.exit()
text = appex.get_text()
text = text.replace(stable_url,'{{ site.baseurl }}')
text = text.replace(test_url,'{{ site.baseurl }}')
dialogs.share_text(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment