Modx script after package installation - modx

I need to write a plugin that needs to create table in database and some setting from installation form. I can easily create form but I have difficulty to run the script after installation to read options and create table. Is it possible at all to run such simple script or maybe you need to create everything like for example models, vehicles and so on?
I would appreciate if anyone could give me directions how to do it. Modx documentation is not clear about this and https://github.com/splittingred/Doodles/tree/production sample repo contains multiple elements I'm not familiar with and I believe don't need at all

Typically you'd use a resolver to run code after the install.
While in the question comments the setup options are discussed, the package attributes there are actually executed to generate the setup options form, not to process the results.
The docs are a tad dated (mostly the screenshots), but Creating a 3rd party build script explains the different parts of a build script, and what they're for, with a fair bit of examples.
The piece you're looking for is this:
$vehicle->resolve('php',array(
'source' => $sources['resolvers'] . 'setupoptions.resolver.php',
));
You'll need to have a $vehicle (perhaps from a category or other object you're adding to the build) and the file in the provided location. Inside the resolver file you can use $object->xpdo as an instance of the modX class to do your thing.

Related

Grav - Parse URL

I want to define a new template called "product".
This template calls an external service and retrieves the information about that specific product. That is easily done with a custom plugin that access the product information. Information on how to do that has been found here.
However, I would like that the URL of the page would be something like:
/product/<id>/<seo-friendly-description>
So I can retrieve in the Twig template both <id> and <seo-friendly-description> which will be used later to retrieve the specific product information.
I have tried to find something that could help in the documentation, without success. Could someone either point me to the right doc section or highlight the basic steps that shall be achieved so I can start solving this issue?
Just in case it helps, I am trying to find something similar to how bottle or other web frameworks work:
#route('/hello/<name>')
def greet(name):
return 'Hello ' + name
I've been building a family recipebook into my own website and I've been working through a similar problem. I haven't quite worked out all the kinks, but my solution is mostly working if you want to checkout my github repo.
In short, you need the plugin to watch what the active route is. If the route matches, you then create the page and populate it using your plugin data.
I haven't quite figured out how to get the active page to highlight in the navigation menu for generated pages, but you might still find this solution helpful.

How to find sources of standard node.js functions

For example, if I'd like to read the source code of the process.chdir JavaScript function, how can I do that?
I can find process.js on github but not sure that's the right file. Is there an easier way to navigate from docs directly to source?
There is not a simple way to navigate directly from the web doc to source. To find the code for a specific function, you have several choices:
Create a small test app that calls the function in question, run node-inspector and step into the function of interest. That will take you right into the source code that your installed version of node.js is running. You can then continue stepping or just examine the local source code shown in the debugger.
Grep your own node.js installation. Since all the .js files are right there and in plain text, you can find it there.
Go to Github like you've done and find the relevant function. This is not always easy to do (as you've discovered) and it doesn't guarantee that you're looking at the source for the exact same version you have installed. If you're a Github wiz, you can always figure out how to see the right version, but that's a bit more work.
If the code you want is actually implemented in native code, then you're going to have to use options 3 or maybe option 2 (if you have native sources locally).

Modifying the conditional build expression in RoboHelp using Extendscript

I'm trying to automate a process for our documentation team. They have a pretty big batch of framemaker files across several books and use RoboHelp to generate EclipseHelp for two different versions of our project.
Each framemaker file has the appropriate tags set to indicate which version a particular piece of documentation applies to. Currently the writers modify the conditional build expression to specify the correct set of tags and run File->Generate->EclipseHelp each time. I can run the generation process just fine, but I can't figure out how to change which tags it's using.
I've read through RoboHelp's scripting guide and the only references I can find to Conditional Build Tags is the ability to create and delete them. I can't find any references to Conditional Build Expressions. Does anyone know any way to modify it from a script? Alternatively, if someone can suggest a different way of organizing RoboHelp/Framemaker that is more conducive, I'm all ears, though I have basically zero familiarity with either.
The Conditional Build Expression forms form of your EclipseHelp Single Source layout. As such your script needs to refer to the tags there.
I'm going to answer with what I found - even though it's only a partial answer - just in case it can help someone, or possibly give someone enough to figure out a more proper answer.
Basically I found that each Single Source Layout has a corresponding *.ssl file. If your layout is called OnlineHelp, it will be (in my experience) OnlineHelp.ssl and will be in the same directory as your .xpj file. The ssl file is just a bunch of xml and has some number of sections. One of the sections will have the same name as the content category where you would go in the UI to change the Conditional Build Expression. In that section is an element named "BuildExpression". Set that to whatever you need and reopen your RoboHelp project. It's a bit of a hack, but I set up a groovy script to do that before running my ExtendScript and it gets the job done.

More efficient ExpressionEngine server moves

I'm trying to find a better way to move my Expression Engine 2 sites from development to live servers. I have a checklist that I go through, starting with running a find and replace for the old/new URLs and server paths, then I update the database config file. This however misses out a huge amount of settings that I then have to go through and change manually, but I don't see why I should need to (unless these are encrypyed somewhere).
For example, I have to change the "Basepath to Template File Directory" in the Global Template Settings manually, along with member settings and a handful of others. There must be a file or entry with these in somewhere that I can change before I upload but I can't find it.
Does anyone know where these are stored?
Those are stored in the database, unless you are using global config variables.
I would highly recommend looking into some sort of config bootstrap. There are quite a few solutions to this, but it's really up to you to pick what's right for your development style / environment(s).
Take a look at the following articles:
http://eeinsider.com/articles/creating-a-robust-config.php-file/
http://boblet.tumblr.com/post/68095239/ee-localhost
http://eeinsider.com/articles/multi-server-setup-for-ee-2/
I've tried those solutions, but in my opinion the best option is NSM config bootstrap.
Check it out here: [http://ee-garage.com/nsm-config-bootstrap][4]
The only thing (currently) missing from these solutions are new config vars regarding file upload paths and locations. You can add those to any of these solutions by adding the variables detailed in this article:
http://expressionengine.com/user_guide/cp/content/files/file_upload_preferences.html#overriding-upload-paths-and-urls-using-configuration-variables
I know I'm late on this one, but for anyone else searching, this plugin is very useful and I have used it on numerous occasions.
ExpressionEngine stores your website URL and Server Path in a ridiculous number of places.
REElocate helps you update these in one simple step.
https://github.com/expressodev/reelocate

What web photo gallery software meets all my pernickety requirements?

I have a collection of photographs (about 30,000) which I'd like to put online. I've tried doing this before, over the years, with static image galleries, applications such as Gallery2, and self-rolled scripts. None have worked that well, as my requirements are fiddly, but it still seems like this should be a solved problem.
My photos are currently organised into folders named YYYY-MM-DD short album title, using Digikam.
I need a system that:
Is Free software, is essentially feature-complete, and has an active developer community.
Allows new photos and albums to be added and updated automatically with little more manual intervention than rsyncing the source directory on my computer to the web server, and rescanning.
Allows visitors to leave comments
Allows re-captcha or equivalant spam filtering and bulk moderation of these comments.
Reads tags from the IPTC Keywords field.
If it finds a tag named "friends", requires the user to enter a password to view.
If it finds a tag named "family", requires the user to enter a different password to view.
If it finds a tag named "private", does not display the photo at all, or even better, does not upload it to the live web server.
Reads descriptions from the IPTC Caption field.
Creates sane permalinks, e.g. http://example.com/2009/03/28/shortalbumtitle/IMG_0001.jpg
I acknowledge that I may be asking for something that doesn't exist, but I hope it does.
I acknowledge that answers may be something like "use Django and code the bits that don't already exist yourself", in which case do you have any tips? :)
Thanks.
Use Django and code the bits that don't already exist yourself.
Seriously. I was going to write that and was tempted not to when I saw you'd written it yourself, but it really does make the most sense if you have any familiarity with it!
I'd start with django-photologue 2. Get a basic gallery with tagging and comments working. You'll need a couple of pl's optional dependencies.
Then I'd write a custom import wrapper that allows you to rsync to a dir and update your library.
Comments are handled internally (through photologue, I think) but if not, there are plenty of comment apps that "just work". There is a recaptcha script that works as just another form field.
PIL can read IPTC
The URL structure is up to you =)
I'm finally getting around to doing this. I'm using a local python script to extract image metadata (tags, captions and timestamp) using pyexiv2, then rotate the image according to its EXIF orientation tag if appropriate, using PIL, and export a hierarchy of files to a temporary directory, where rsync uploads it to my host, and a remote python script (actually a Django app) imports the metadata into a Django DB.

Resources