Skip to content

Instantly share code, notes, and snippets.

@Zegnat Zegnat/setup.md
Last active Jun 5, 2018

Embed
What would you like to do?
Setting up an offline Micropub testing environment, combining 3 separate PHP projects!

Testing Micropub, completely offline, with nanopub, Selfauth, and Mintoken.

this setup should be done in a directory that is being served at http://offlinepub.test/. When done, it should be possible to point a Micropub client at that URL and post.

IMPORTANT: This does not lead to a production safe setup. The tokens DB is put in a public directory, the APP_KEY for Selfauth is made known through this post, etc. But for offline testing, all should be good.

Create index.html with:

<!doctype html>
<html>
  <head>
    <link rel="authorization_endpoint" href="http://offlinepub.test/auth/">
    <link rel="token_endpoint" href="http://offlinepub.test/token/endpoint.php">
    <link rel="micropub" href="http://offlinepub.test/mp/nanopub.php">
  </head>
  <body></body>
</html>

Run the following things in the terminal. You may need to copy it line-by-line as my bash-foo is truly weak.

git clone --depth=1 git@github.com:dg01d/nanopub.git mp
cd mp;composer install;cd ..
sed -i.bak 's/post_to_api("https:\/\/switchboard/\/\/post_to_api("https:\/\/switchboard/' mp/nanopub.php
sed -i.bak "s/'siteUrl' => 'https:\/\/example.com\/',/'siteUrl' => 'http:\/\/offlinepub.test\/',/" mp/configs.php
sed -i.bak "s/'tokenPoint' => 'https:\/\/tokens.indieauth.com\/token',/'tokenPoint' => 'http:\/\/offlinepub.test\/token\/endpoint.php',/" mp/configs.php
mkdir -p ./content/link ./content/article ./content/like ./content/micro
git clone --depth=1 git@github.com:Inklings-io/selfauth.git auth
mv ./auth/config.php.example ./auth/config.php
sed -i.bak "s/APP_URL', ''/APP_URL', 'http:\/\/offlinepub.test\/auth\/'/" ./auth/config.php
sed -i.bak "s/APP_KEY', ''/APP_KEY', '166745a2255605f74bec49ce5829fc08a2a8c20f78ac598ee918eaf3775c5f31'/" ./auth/config.php
sed -i.bak "s/USER_HASH', ''/USER_HASH', '474b5c6d3123fdc961989dec4b955244'/" ./auth/config.php
sed -i.bak "s/USER_URL', ''/USER_URL', 'http:\/\/offlinepub.test\/'/" ./auth/config.php
git clone --depth=1 git@github.com:Zegnat/php-mintoken.git token
sqlite3 ./token/tokens.db < ./token/schema.sql
sqlite3 ./token/tokens.db 'INSERT INTO settings VALUES ("endpoint", "http://offlinepub.test/auth/");'
sed -i.bak "s/SQLITE_PATH', ''/SQLITE_PATH', 'tokens.db'/" ./token/endpoint.php
rm mp/*.bak token/*.bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.