https://codepen.io/fapnip/full/GRjwPXP
It's called Eos Magpie, because like a common myth surrounding the magpie, it lets you grab shiny things from Eos tease scripts.
Use it to copy data (pages, images, etc.) from one Eos script source, merge it with another, and download the merged JSON.
Let me know if you find it useful, or have issues. Built for my own use, but figured some of you may find it helpful.
(Updated to make it easier to recover images missing in target from a source that has one or more of the given images.)
Here's some things you can embed in your tease's Init Script to tell Eos Magpie what to do:
Name / Version of tease
So Magpie can know what your tease's name and version is, simply add the following to the start of your Init Script
Code: Select all
/************************
* My Tease Name v1.2.3
*/
To display a message to users of Eos Magpie that have entered your tease as the "source", add the following anywhere in your Init Script
Code: Select all
/*--magpie-warn
Please be nice and let me know if you're using my tease.
Thanks.
*/
To tell Magpie to automatically select the init script and source pages that are different or missing in the target if the tease name for the source and target are the same, or if the target has an empty init script, add the following anywhere in your Init Script:
(If the page already exists in target, it WILL be marked for replacement.)
Code: Select all
/*--auto-magpie-core
my-page-that-should-be-updated
and-so-on
pages-names-*
*/
(If the page already exists in target, it will NOT be marked for replacement.)
Code: Select all
/*--auto-magpie-require
my-page-that-is-needed
another-required-page
*/
To tell Magpie to keep changes in a specific action when updating a page, place an eval containing the --auto-magpie-merge:[unique-merge-id] tag right before the given action. (Note: Replace "[unique-merge-id]" with a unique (relative to page) string. This allows magpie to know which actions to merge in target and source.):
Code: Select all
/*--auto-magpie-merge:my-merge-id-1121 */
Creating a "Magpie Module"
A Magpie Module is a group of actions and evals that can be shared with other tease authors, and allows them to easily install and update the module in their own teases using Magpie.
To create a module, add an IF action to you start page. In that if action, set the condition to something like:
Code: Select all
!window.MyMagpieModule /* MPEM::MyMagpieModule v1.0.0 */
In the IF's actions, you must have, at a minimum, an Eval action that creates your Module's object/prototype. For example:
Code: Select all
// We always want to wrap in an immediate function to avoid global namespace pollution.
;(function(){
// First some optional header information so Magpie can display things to users
/***************************
* MyMagpieModule
****************************
MPED--author::My Milovana User Name
MPED--description::
A description of an otherwise useless example Magpie Module, displayed in Magpie
See:
https://milovana.com/forum/posting.php?mode=edit&f=4&p=294482
::--description
*/
// Now the real code for the Module
if (window.MyMagpieModule) return // already installed. Get out.
// Define a constructor method for our module prototype
funciton MyMagpieModule(opts) {
// If we didn't get any options, make some default ones
opts = opts || {
name: 'Billy the Bob',
level: 0,
}
this.name = opts.name
this.level = opts.level || 0
}
// Create some methods
MyMagpieModule.prototype.getName = function () {
return this.name
}
MyMagpieModule.prototype.getLevel = function () {
return this.level
}
MyMagpieModule.prototype.incrementLevel = function () {
this.level++
}
// Export our module to the world
window.MyMagpieModule = MyMagpieModule
})()
Code: Select all
// This module example uses a prototype, so we need to create an instance of it to use it.
if (!window.myUselessModuleInstance) {
// We don't have a global instance built yet, so let's do that.
window.myUselessModuleInstance = new MyMagpieModule({
name: 'Super Fly',
level: 2,
})
}
// Now that we have an instance created, we can use it
console.log("Here's some useless information:", myUselessModuleInstance.getName(), myUselessModuleInstance.getLevel())
viewtopic.php?f=2&t=24275