Giter Club home page Giter Club logo

gs-front-router's Introduction

GetSimple Front Router Plugin

Executes user-defined actions depending on the requested page URL. Designed to be used in conjunction with other plugins in order relate page actions to specific URL structures (without modifying any .htaccess files).

Requirements

Features

  • Select page content based on the structure of the URL
  • Improve SEO for your site by having informative site URLs
  • Easily create custom error pages for specific page types
  • Combine functionality from other plugins to display your own custom page content
  • Create front page routes for your own plugins by registering hooks with this plugin
  • Available in English, Italian, French, German and Russian
  • Works with and without Fancy/Pretty URLS enabled (v0.3+)
  • Build RESTful API services/endpoints (v0.5.0+)

Screenshots

screenshot of admin panel

screenshot of successful route

Getting Started

  1. Install and enable the plugin.
  2. Go to Plugins -> Manage Routes.
  3. Add, edit and delete your routes.
  4. Visit a URL on your site that matches the pattern to test your route.

Check out the wiki for more information.

Examples

More examples in the wiki and the examples folder of the plugin.

Wiki

Documentation, API, tutorials and contribution guidelines are all available on the wiki. Contributions are welcome.

License

GetSimple Front Router is licensed under MIT.

Contributors

  • dimayakovlev - Russian translation, CSS enhancements in 0.4.2
  • tablatronix - Enhancements for Version 0.4.0
  • cnb - Spanish translation

Copyright

All rights reserved.

gs-front-router's People

Contributors

cnb avatar dimayakovlev avatar lokothodida avatar tablatronix avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gs-front-router's Issues

Add RESTful service creation from REST plugin

Proposal

Eventually integrate the RESTful API plugin into the front router, since it would be much more useful for the REST API plugin to use the front router for building a service's URLs.

Example

Route

api/v1/users/([a-z0-9-]+)

Method

GET

Header Type

json

Action

<?php

$slug   = $args[0];
$result = array('version' => '1.0');

// Imagine there are functions user_exists() and get_user_profile() to check for
// profiles and get existing profiles:
if (user_exists($slug)) {
  $result['user'] = get_user_profile($slug);
  $result['success'] = true;
} else {
  $result['success'] = false;
}

// Result is automatically encoded to JSON by the plugin
return $result;

Conflict with other plugins accessing $data_index object as a SimpleXML object

Example

I18N Special Pages has a getFields method which expects the $data_index object to be a SimpleXML object:

    // i18n_specialpages/specialpages.class.php
    // at roughly line 275 ($data is $data_index)
      foreach ($data->children() as $child) {
        if (!in_array($child->getName(), $stdfields) && (string) $child) {
          $fields[$child->getName()] = (string) $child;
        }
      }

The current FrontRouter code makes $data_index a plain object by merging two (cast) arrays, so the merge should instead just bolt these properties on, instead of doing a full merge.

Add example plugins to the repository

Proposal

  • Demonstrable proof that the examples in the wiki work would be helpful.
  • They should exist in a subdirectory examples, and be single-file examples that demonstrate how to use front-router to integrate functionality from other plugins.
  • Since they are examples, they needn't capture all edge-cases, and should be relatively simple (if possible, under 200 lines? (excluding comments)).
  • Because they are single-file, they should be usable by simply copy-pasting them into the /plugins directory, and (at most) renaming them not to conflict with an existing plugin.
  • Open to many other examples/submissions from other users!
front_router
  - lang
  ...
  - examples
    - comments.php
    - file_listing.php
    - gallery.php
    - news.php

Save Changes button doesn't work

Test Front Router v0.4.1 with clean GS 3.3.13. I can add routes, but I can't save changes. While there are no routes, save work fine.

I can't get to work properly

Front Router work for me only if route is (.*). If I try others routes FrontRouterRouter::executeFront($url) always return false.

Improvements to administration panel UI

  • 45955c1 Put placeholder text for newly added routes and their actions
  • bd773dc Make routes collapsible (for easier vertical scrolling)
  • 584df8c Update route container divs CSS to match current GetSimple admin panel UI (metadata window for page options)
  • 114b7ae Add quick-filter option to search for routes (like page filtering on pages.php)
  • cc3a5a2 Add link in header to the repo (for wiki/documentation)
  • 14c2a75 Add Save Changes button to top of page as well (useful if routes list gets long)
  • 504d595 Add buttons for expanding/collapsing all routes at once
  • f389a9b Add total # of routes to bottom of the page
  • 63d5903 Set syntax highlighting language to PHP

plugin enhancements

use the data_index filter as your hook

// filter to modify data_index obj
$data_index = exec_filter('data_index',$data_index);

Your function can still accept a return array then you can merge into into the data_index obj, it should be ok. and allows users to set all page vars, also i am not exactly sure I understand the callback on content..
I guess you could check if callable if not just set content to the string also.

Also the way you are obj buffering into content does not work, since the global $content is already set, you are just putting it back into data_index, which nothing uses.

I will be glad to fix this all up and let you PR it back in. But i want to make sure I understand what you intended, there are things mentioned in the readme that i am unsure how you would do them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.