Mike Rockett

module
Jumplinks

428 posts in this topic

Jumplinks for ProcessWire

jumplinks.png?maxAge=2592000&style=flat-

Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.

The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.

Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.

Under Development: 2.0, to be powered by FastRoute

As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.

View on Github
Download via the Modules Directory
Read the docs

Features

The most prominent features include:

  • Basic jumplinks (from one fixed route to another)
  • Parameter-based wildcards with "Smart" equivalents
  • Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks)
  • Destination Selectors (for finding and redirecting to pages containing legacy location information)
  • Timed Activation (activate and/or deactivate jumplinks at specific times)
  • 404-Monitor (for creating jumplinks based on 404 hits)

Additionally, the following features may come in handy:

  • Stale jumplink management
  • Legacy domain support for slow migrations
  • An importer (from CSV or ProcessRedirects)

Feedback & Feature Requests

I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.

Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.

Open Source

Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.

Enjoy!  :grin:

23 people like this

Share this post


Link to post
Share on other sites

Wow!  Nice work Mike!  I'll try to carve some time later in the week to give this a thorough test run.

1 person likes this

Share this post


Link to post
Share on other sites

@renobird -- Glad you like it! Yeah, please; I'll appreciate that very much.

1 person likes this

Share this post


Link to post
Share on other sites

I've made few changes, which I'll be uploading tomorrow morning as v0.1.1. Some of it is to do with bettering my code (specifically in the way of Regular Expressions), and the rest of it is to do with better path cleaning, and a few backend CSS fixes.

1 person likes this

Share this post


Link to post
Share on other sites

<development post>

New Alpha Release - 0.1.1

The full changelog is below, but I want to highlight an important addition to the module. In its present state, this  new feature is classified as an experiment, and so it may not make it into the final 1.0 release.

The experiment is called Enhanced Path Cleaning which basically splits and hyphenates TitleCased wildcard-captures, as well as those containing abbreviations or acronyms in capital letters.

This is quite handy for those who come from a DNN background, or some other ASP-based framework.

As an example, EnvironmentStudy would become environment-study and NASALaunch would become nasa-launch.

It also changes any numbers that are not broken out with hyphens.

You'll need to turn the experiment on in the module's config page, as it is off by default.

Example from scan log:

Page not found; scanning for redirects...

    - Checked at: Tue, 06 Jan 2015 10:20:20 +0200
    - Requested URL:
http://processwire.local/NAGMagazine/home/tabid/1027/default.aspx
    - PW Version: 2.5.13

[ASPX Content]

    - Source Path (Unescaped): {path}/tabid/{id}/Default.aspx
    - Source Path (Stage 1): {path:segments}/tabid/{id:num}/Default.aspx
    - Source Path (Stage 2): ([\w/_-]+)/tabid/(\d+)/Default.aspx
    - Destination Path (Original): {path}/?otid={id}
    - Destination Path (Compiled): processwire.local/{path}/?otid={id}
    - Destination Path (Converted): processwire.local/nag-magazine/home/?otid=1027

Match found! We'll do the following redirect (301, permanent) when Debug Mode has been turned off:

    - From URL: processwire.local/NAGMagazine/home/tabid/1027/default.aspx
    - To URL: processwire.local/nag-magazine/home/?otid=1027

Changelog

[5 Jan]

- Modified Module Config page
- Simplified wildcard and cleanPath() expressions
- Added 'segments' check to 'segments' smart wildcard, where only 'path' existed before
- Added 'num' check to 'num'
- Changed ellipses style (added border)
- Made Legacy Redirects temporary (302)
- Fixed CSS #ModuleEditForm declaration so other modules are not impacted by the style change
- Changed CSS p.notes to p.parNotes so we don't conflict with anything else
- Other small semantic code modifications

[6 Jan]
- Added Experiments fieldset in Module Config
- Added Enhanced Path Cleaning Experiment
- Removed license file, refer to
http://mikeanthony.mit-license.org/

2 people like this

Share this post


Link to post
Share on other sites

Sometimes during a migration people have second thoughts and want to make some adjustments after redirects are in place. How about an option to redirect as 302 for a while (think of it as a probationary period) before automatically converting to 301 (so we don't forget).

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for bringing that up, Steve. I did indeed think about this earlier, and made a comment on my to do list: "Find out if we should prevent the deletion of 301s".

Granted, that isn't the right question to ask, but it reminds me to look at the various options regarding this.

I think your idea is quite good. After such period, should we prevent the deletion of redirects?

And what does everyone else think about this?

Share this post


Link to post
Share on other sites

<development post>

New Alpha Release - 0.1.2 (Breaking Changes)
 
This module introduces a new feature: Mapping Collections (this is the final name for it).
 
The feature allows you to map key/value pairs to your redirects so that you need not repeat yourself.

An example would be the following: Redirect /blog.php?id=2309 to /hello-world/, by using the following redirect:

blog.php?id={id}      =>      {id|pages}

You're wondering, what's {id|blog}? Simply put, that's called a mapping reference, which refers to an entry in a Mapping Collection.

A Mapping Collection, in this case, would look something like this:

1=a-post
2=another-post
3=third-post
...
2309=hello-world

So, when it comes time to redirect, it will scan the provided id against the collection called blog and, if it finds a match, will redirect accordingly.

If, however, there is no match, the segment that asked for the mapping will be left out, resulting in an invalid URL. I may get it to insert the original capture instead.

Some Screenshots:

post-2289-0-00830100-1420570260_thumb.pn

--

post-2289-0-03432300-1420568167_thumb.pn

--

post-2289-0-99072900-1420568173_thumb.pn

--

Full Changelog for this release:

[6 Jan]
- Some refactoring; moving code blocks from main module to UtilityProcess
- [New Feature] Mapping Collections
- Changed module title to Advanced Redirects [ALPHA]
 
Breaking Changes: The DB schemas have changed in this release. If you already have 0.1.0 or 0.1.1 installed, please uninstall it first.
3 people like this

Share this post


Link to post
Share on other sites

Okay wait, something broke with collections. Looking into it...

Update: Nevermind, I didn't test properly. Hehe! It works :)

Share this post


Link to post
Share on other sites

At this point, the module is quite feature-rich. As such, I'm pausing development. This gives time for those testing the module to do so without me introducing new things every three seconds, and it also gives me time to prepare for the whole 'back to work' thing - I return on Monday, and need to prepare for it.

I'll still be here to discuss things, but there won't be any changes for about two weeks.

Looking forward to the results/feedback of everyone's testing. :)

Update: Lol, the stuff I had to do couldn't be done today - so there are a few changes up on the repo now.

1 person likes this

Share this post


Link to post
Share on other sites

<development post>

Right, in terms of features: I need feedback. As mentioned, the module is feature-rich in its current state. Normal and wildcard redirects, along with mapping collections, makes this module ready for almost anything. But there are two features which I haven't implemented yet. They are:

Variables

This is probably something that may never get used. I needed it once upon a time for social accounts and user names, but it really doesn't seem practical. The idea is this: You create a redirect, and use {@something} somewhere in the destination path. Based on your variables table, it would then be replaced accordingly. Like I said, doesn't seem to be something that anyone would really make use of. However, I would like some feedback on it.

Just in Time Replacements

These would probably be used much more - they are quite handy. Say, for example, you had the following page structure in your old site:

  1. About Us.html
  2. Services.html
  3. Contact Us.html

Then you have the following redirect set up:

Source Path: {page:any}.html

Destination Path: {page}/

Naturally, those pages would redirect to:

  1. about-us/
  2. services/
  3. contact-us/

But now, you've decided to use different page names in your new PW site - for example: who-we-are, solutions, and connect.

Considering we're using a wildcard redirect here (saves time for a lot of pages), we don't want define more redirects to go the new pages. This is where JIT Replacements comes in. It's like a simple find and replace:

Find                                                    Replace

about-us                      who-we-are

services                      solutions

contact-us                    connect

 

 

And, therefore:

Request                                             Destination

About Us.html                 who-we-are/

Services.html                 solutions/

Contact Us.html               connect/

 

In a nutshell, this saves a redirect. One might argue that they may as well create redirects for each and every page, but you have to consider that not every page name will change. And what happens if you move all the pages down a level? You'd only need to change one redirect.

So, I'd like some feedback on this too. Will you find it useful?

Until I've got some decent feedback, I'm not going to add these features. With that said, and because I know some people are eager to use the module now, I'm going to release a beta. I haven't found any bugs as yet, and so I think its ready for beta status.


(Oh, and I'll add the history feature before beta release - nearly forgot about that!)

Share this post


Link to post
Share on other sites

Mike, my humble opinion, that you have already huge amount of features. Adding more makes starting to use this module in simpler cases more difficult: "I installed it and it felt like total overkill for my needs.". Of course we have the current redirects module for those needs... But I think your feature set is great and would much rather see the current as stable instead of more scenarios supported.

Share this post


Link to post
Share on other sites

Okay - I understand where you're coming from.

Do you think it would be useful to have a redirect log? Or just a simple hit counter like you had?

And have you encountered any problems as yet?

Share this post


Link to post
Share on other sites

Have just done a big cleanup.

Main things still to do: (also see the task list on GH)

- History/hit counter (I think the latter would be adequate)

- Import/export (doing that today)

I'm also going to reverse a few things to make this compatible with 2.5.3.

2 people like this

Share this post


Link to post
Share on other sites

Nearly done with the importing side of things. Hit counter will be quick and easy.

Last thing I need to ask:

Currently, a 302 redirect will occur if it has a start/end time assigned. Otherwise, it will do a 301. Should we include functionality to let the end-user choose if it should be 301/302? Or should we stick with the previous idea of a probation period?

Share this post


Link to post
Share on other sites

Just pushed 0.9.1 to the repo. Sorry, haven't had time to finish up faster.

Importing from CSV is done (seemingly). Will also support importing from Redirects module, if you don't want to run both.

1 person likes this

Share this post


Link to post
Share on other sites

Okay, so I've actually decided to rename the module to ProcessJumplinks. I prefer it.

https://github.com/mike-anthony/ProcessJumplinks

Hit counter is done. Still need to work on importing from Redirects module - I'll do that tomorrow as I'm super-tired now.

I don't think I'm going to make this compatible with the current stable (2.5.3). If you really want me to, please let me know.

:-)


Will also work on docs soon - though my intro post covers a lot. Nice to have docs, however.

5 people like this

Share this post


Link to post
Share on other sites

Hi Pete - I will do so shortly. Thanks.

Edit - though, the module isn't compatible with 2.5, so I can't add it... Could we perhaps add a 2.6-dev to that list?

2 people like this

Share this post


Link to post
Share on other sites

Hey Mike - any thoughts of making is possible to add redirects via an API call. After the discussion this morning about imported Wordpress rewriting (https://processwire.com/talk/topic/8869-wordpress-url-rewrites/), I would like to add this functionality to MigratorWordpress so that rewrites are automatically added. Obviously I can do it through SQL inserts, but thought an API method would be nice.

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      First a note about my other modules...
      I have three existing modules that are similar in that they allow restrictions to be placed on repeating inputfields: Limit Repeater, Limit PageTable, Limit Table
      Restrict Repeater Matrix takes a different approach to the module configuration from those other modules. The module settings for Restrict Repeater Matrix are applied in the field settings rather in a module config screen. I think this new approach is better, but it means that it isn't practical to create different settings for different roles via the admin interface. Instead the module has a hookable method, allowing roles to be targeted and other advanced usages to be achieved via a hook. The result is that the module is more flexible.
      I intend to transition my other modules to the same approach over the coming weeks, but because this will result in breaking changes I will be releasing the updated modules under new names ("Restrict Repeater", etc) to avoid users upgrading via the Upgrades module without full awareness of the changes. The old modules will be marked as deprecated.
       
      Restrict Repeater Matrix
      A module for ProcessWire CMS/CMF. Allows restrictions and limits to be placed on Repeater Matrix fields.
      For any matrix type in a Repeater Matrix field you have the option to:
      Prevent drag-sorting of items Prevent cloning of items Prevent toggling of the published state of items Prevent trashing of items Limit the number of items that may be added to the inputfield Please note that restrictions and limits are applied with CSS/JS so should not be considered tamper-proof.
      Usage
      Install the Restrict Repeater Matrix module.
      For each matrix type created in the Repeater Matrix field settings, a "Restrictions" fieldset is added at the bottom of the matrix type settings:

      For newly added matrix types, the settings must be saved first in order for the Restrictions fieldset to appear. Set restrictions for each matrix type as needed. A limit of zero means that no items of that matrix type may be added to the inputfield.
      Setting restrictions via a hook
      Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking RestrictRepeaterMatrix::checkRestrictions. This allows for more focused restrictions, for example, applying restrictions depending on the template of the page being edited or depending on the role of the user.
      The checkRestrictions() method receives the following arguments:
      $field This Repeater Matrix field $inputfield This Repeater Matrix inputfield $matrix_types An array of matrix types for this field. Each key is the matrix type name and the value is the matrix type integer. $page The page that is open in ProcessPageEdit The method returns a multi-dimensional array of matrix types and restrictions for each of those types. An example of a returned array:

      Example hooks
      Prevent the matrix type "images_block" from being added to "my_matrix_field" in a page with the "basic-page" template:
      $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $page = $event->arguments('page'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && $page->template->name === 'basic-page') { $type_restrictions['images_block']['limit'] = 0; } $event->return = $type_restrictions; });  
      Prevent non-superusers from trashing any Repeater Matrix items in "my_matrix_field":
      $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && !$this->user->isSuperuser()) { foreach($type_restrictions as $key => $value) { $type_restrictions[$key]['notrash'] = true; } } $event->return = $type_restrictions; });  
      https://github.com/Toutouwai/RestrictRepeaterMatrix
    • By bernhard
      Hi,
      just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone.
      https://gitlab.com/baumrock/RockDummyData/
      easy example:
      $rdd = $modules->get('RockDummyData'); for($i=0; $i<15; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>"; } more advanced:
      $json = new stdClass(); $json->data = array(); $rdd = $modules->get('RockDummyData'); for($i=0; $i<3000; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); $obj = new stdClass(); $obj->name = $dummy->forename . ' ' . $dummy->surname; $obj->position = $dummy->job; $obj->office = $dummy->city; $obj->color = $dummy->color; $obj->start_date = new stdClass(); $obj->start_date->display = date('d.m.Y',$dummy->timestamp); $obj->start_date->sort = $dummy->timestamp; $obj->salary = rand(0,10000); $json->data[] = $obj; } echo json_encode($json); you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module
    • By AndySh
      Hello!
      I need your assistance please. I purchased the module FormBuilder. Unfortunately, the module discontinued delivering customer submissions to e-mail box specified in the module settings. Direct mailing to the e-mail box works OK. The module settings stays the same and are correct, like "Send e-mail to administrator(s) is checked. The last version of FormBuilder 3.0 has been installed. Please advise how to resolve the issue becase I cannot get orders from customers anymore (((
    • By kixe
      As described in this post (https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742) the option 'Name Format Children' under the tab 'Family' in template settings doesn't work properly and also not as expected. I had a look inside the code and made some changes which are working properly, which offers much more options, more consistency and less code too.

      The result is the following. You have 3 Options for generating name and title, which could be combined in endless variations.
      Name is always derived from title, same like creating pages manually.
      type date: if function detects # character anywhere in the string, conversion will be: deletion of # and string will be used as format parameter for PHP date() function type field: if string is a fieldname of the parent page the value of this field will be used type string: if string doesn't fit to the 2 preceeding it will be taken as it is All parts (separated by comma) will be composed in the order of setting. You can use unlimited numbers of parts

      I made a pull request on github: https://github.com/ryancramerdesign/ProcessWire/pull/831

      Example screenshots

      Setting ...


      will result in


       
    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
       
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend