Changeset 1421


Ignore:
Timestamp:
02/23/18 11:59:35 (4 months ago)
Author:
gogo
Message:

Add support for using external plugins with XinhaEasy.js and add Xinha.pluginManifest to describe location of built in plugins (and modules) without needing to "ping" them.

The pluginManifest can be generated by bash script contrib/generate-plugin-manifest.sh and should be done and updated before release.

For external/custom plugins when using XinhaEasy.js simply set the xinha_plugins option thusly...

xinha_plugins: [ 'BuiltInPlugin1', { from: '/path/to/custom/plugins', load: 'CustomPlugin1' } ]

It works even for the PHP plugins, MootoolsFileManager? and Linker when using Xinha from a CDN etc, as long of course as they have the contrib php-xinha.php available to them.

Location:
trunk
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1418 r1421  
    528528Xinha.RE_url      = /(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_\-]{2,}(\.[a-z0-9_\-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i; 
    529529 
    530  
     530/** This object records for known plugins where they can be found 
     531 *  this is used by loadPlugin to avoid having to test multiple locations 
     532 *  when we can reasonably know where the plugin is because it is 
     533 *  part of the distribution. 
     534 *  
     535 *  This becomes important because of CoRS and a problem with Amazon S3 
     536 *  in which it does not poroduce a necessary header to Chrome if Chrome 
     537 *  first requests a script as part of loading a <script> and then 
     538 *  "pings" with XMLHTTPRequest, depending on that bit of a race-condition 
     539 *  which one hits cache first things can go wonky. 
     540 *  
     541 *  By avoiding the need to ping things in the distribution, we should 
     542 *  not have that problem I think. 
     543 */ 
     544 
     545Xinha.pluginManifest = { 
     546  Abbreviation:         { url: _editor_url+'plugins/Abbreviation/Abbreviation.js' }, 
     547  AboutBox:             { url: _editor_url+'modules/AboutBox/AboutBox.js' }, 
     548  BackgroundImage:      { url: _editor_url+'unsupported_plugins/BackgroundImage/BackgroundImage.js' }, 
     549  CharacterMap:         { url: _editor_url+'plugins/CharacterMap/CharacterMap.js' }, 
     550  CharCounter:          { url: _editor_url+'plugins/CharCounter/CharCounter.js' }, 
     551  ClientsideSpellcheck: { url: _editor_url+'unsupported_plugins/ClientsideSpellcheck/ClientsideSpellcheck.js' }, 
     552  ColorPicker:          { url: _editor_url+'modules/ColorPicker/ColorPicker.js' }, 
     553  ContextMenu:          { url: _editor_url+'plugins/ContextMenu/ContextMenu.js' }, 
     554  CreateLink:           { url: _editor_url+'modules/CreateLink/link.js' }, 
     555  CSSDropDowns:         { url: _editor_url+'plugins/CSSDropDowns/CSSDropDowns.js' }, 
     556  CSSPicker:            { url: _editor_url+'plugins/CSSPicker/CSSPicker.js' }, 
     557  DefinitionList:       { url: _editor_url+'plugins/DefinitionList/DefinitionList.js' }, 
     558  Dialogs:              { url: _editor_url+'modules/Dialogs/dialog.js' }, 
     559  DoubleClick:          { url: _editor_url+'unsupported_plugins/DoubleClick/DoubleClick.js' }, 
     560  DynamicCSS:           { url: _editor_url+'plugins/DynamicCSS/DynamicCSS.js' }, 
     561  EditTag:              { url: _editor_url+'plugins/EditTag/EditTag.js' }, 
     562  EncodeOutput:         { url: _editor_url+'plugins/EncodeOutput/EncodeOutput.js' }, 
     563  Equation:             { url: _editor_url+'plugins/Equation/Equation.js' }, 
     564  ExtendedFileManager:  { url: _editor_url+'unsupported_plugins/ExtendedFileManager/ExtendedFileManager.js' }, 
     565  FancySelects:         { url: _editor_url+'plugins/FancySelects/FancySelects.js' }, 
     566  Filter:               { url: _editor_url+'unsupported_plugins/Filter/Filter.js' }, 
     567  FindReplace:          { url: _editor_url+'plugins/FindReplace/FindReplace.js' }, 
     568  FormOperations:       { url: _editor_url+'plugins/FormOperations/FormOperations.js' }, 
     569  Forms:                { url: _editor_url+'plugins/Forms/Forms.js' }, 
     570  FullPage:             { url: _editor_url+'plugins/FullPage/FullPage.js' }, 
     571  FullScreen:           { url: _editor_url+'modules/FullScreen/full-screen.js' }, 
     572  Gecko:                { url: _editor_url+'modules/Gecko/Gecko.js' }, 
     573  GenericPlugin:        { url: _editor_url+'plugins/GenericPlugin/GenericPlugin.js' }, 
     574  GetHtml:              { url: _editor_url+'plugins/GetHtml/GetHtml.js' }, 
     575  HorizontalRule:       { url: _editor_url+'plugins/HorizontalRule/HorizontalRule.js' }, 
     576  HtmlEntities:         { url: _editor_url+'plugins/HtmlEntities/HtmlEntities.js' }, 
     577  HtmlTidy:             { url: _editor_url+'unsupported_plugins/HtmlTidy/HtmlTidy.js' }, 
     578  ImageManager:         { url: _editor_url+'unsupported_plugins/ImageManager/ImageManager.js' }, 
     579  InlineStyler:         { url: _editor_url+'modules/InlineStyler/InlineStyler.js' }, 
     580  InsertAnchor:         { url: _editor_url+'plugins/InsertAnchor/InsertAnchor.js' }, 
     581  InsertImage:          { url: _editor_url+'modules/InsertImage/insert_image.js' }, 
     582  InsertMarquee:        { url: _editor_url+'unsupported_plugins/InsertMarquee/InsertMarquee.js' }, 
     583  InsertNote:           { url: _editor_url+'plugins/InsertNote/InsertNote.js' }, 
     584  InsertPagebreak:      { url: _editor_url+'plugins/InsertPagebreak/InsertPagebreak.js' }, 
     585  InsertPicture:        { url: _editor_url+'unsupported_plugins/InsertPicture/InsertPicture.js' }, 
     586  InsertSmiley:         { url: _editor_url+'plugins/InsertSmiley/InsertSmiley.js' }, 
     587  InsertSnippet2:       { url: _editor_url+'plugins/InsertSnippet2/InsertSnippet2.js' }, 
     588  InsertSnippet:        { url: _editor_url+'plugins/InsertSnippet/InsertSnippet.js' }, 
     589  InsertTable:          { url: _editor_url+'modules/InsertTable/insert_table.js' }, 
     590  InsertWords:          { url: _editor_url+'plugins/InsertWords/InsertWords.js' }, 
     591  InternetExplorer:     { url: _editor_url+'modules/InternetExplorer/InternetExplorer.js' }, 
     592  LangMarks:            { url: _editor_url+'plugins/LangMarks/LangMarks.js' }, 
     593  Linker:               { url: _editor_url+'plugins/Linker/Linker.js' }, 
     594  ListOperations:       { url: _editor_url+'plugins/ListOperations/ListOperations.js' }, 
     595  ListType:             { url: _editor_url+'plugins/ListType/ListType.js' }, 
     596  MootoolsFileManager:  { url: _editor_url+'plugins/MootoolsFileManager/MootoolsFileManager.js' }, 
     597  NoteServer:           { url: _editor_url+'unsupported_plugins/NoteServer/NoteServer.js' }, 
     598  Opera:                { url: _editor_url+'modules/Opera/Opera.js' }, 
     599  PasteText:            { url: _editor_url+'plugins/PasteText/PasteText.js' }, 
     600  PersistentStorage:    { url: _editor_url+'unsupported_plugins/PersistentStorage/PersistentStorage.js' }, 
     601  PreserveScripts:      { url: _editor_url+'plugins/PreserveScripts/PreserveScripts.js' }, 
     602  PreserveSelection:    { url: _editor_url+'plugins/PreserveSelection/PreserveSelection.js' }, 
     603  PSFixed:              { url: _editor_url+'unsupported_plugins/PSFixed/PSFixed.js' }, 
     604  PSLocal:              { url: _editor_url+'unsupported_plugins/PSLocal/PSLocal.js' }, 
     605  PSServer:             { url: _editor_url+'unsupported_plugins/PSServer/PSServer.js' }, 
     606  QuickTag:             { url: _editor_url+'plugins/QuickTag/QuickTag.js' }, 
     607  SaveOnBlur:           { url: _editor_url+'plugins/SaveOnBlur/SaveOnBlur.js' }, 
     608  SaveSubmit:           { url: _editor_url+'plugins/SaveSubmit/SaveSubmit.js' }, 
     609  SetId:                { url: _editor_url+'plugins/SetId/SetId.js' }, 
     610  SmartReplace:         { url: _editor_url+'plugins/SmartReplace/SmartReplace.js' }, 
     611  SpellChecker:         { url: _editor_url+'unsupported_plugins/SpellChecker/SpellChecker.js' }, 
     612  Stylist:              { url: _editor_url+'plugins/Stylist/Stylist.js' }, 
     613  SuperClean:           { url: _editor_url+'plugins/SuperClean/SuperClean.js' }, 
     614  TableOperations:      { url: _editor_url+'plugins/TableOperations/TableOperations.js' }, 
     615  Template:             { url: _editor_url+'unsupported_plugins/Template/Template.js' }, 
     616  UnFormat:             { url: _editor_url+'unsupported_plugins/UnFormat/UnFormat.js' }, 
     617  UnsavedChanges:       { url: _editor_url+'plugins/UnsavedChanges/UnsavedChanges.js' }, 
     618  WebKitResize:         { url: _editor_url+'plugins/WebKitResize/WebKitResize.js' }, 
     619  WebKit:               { url: _editor_url+'modules/WebKit/WebKit.js' }, 
     620  WysiwygWrap:          { url: _editor_url+'plugins/WysiwygWrap/WysiwygWrap.js' } 
     621}; 
    531622 
    532623/** 
     
    40194110    return Xinha.externalPlugins[plugin][0]; 
    40204111  } 
     4112   
     4113  // This is ued by multiStageLoader when it's trying to find a plugin 
     4114  // after it's tried the normal directory, so as long as it's in the pluginManifest 
     4115  // then this shouldn't be hit, but just incase we will respect this request 
     4116  if (forceUnsupported) 
     4117  { 
     4118    return _editor_url + "unsupported_plugins/" + plugin ; 
     4119  } 
     4120   
     4121  // Just in case we fudge the pluginManifest for a given plugin 
     4122  // pull the directory from there 
     4123  if(typeof Xinha.pluginManifest[plugin] != 'undefined') 
     4124  { 
     4125    return Xinha.pluginManifest[plugin].url.replace(/\/[a-zA-Z0-9_-]+\.js$/, ''); 
     4126  } 
     4127   
    40214128  if (forceUnsupported || 
    40224129      // If the plugin is fully loaded, it's supported status is already set. 
     
    41314238    { 
    41324239      Xinha._loadback(Xinha.externalPlugins[pluginName][0]+Xinha.externalPlugins[pluginName][1], callback, this, pluginName); 
     4240    } 
     4241    else if(Xinha.pluginManifest[pluginName]) 
     4242    { 
     4243      Xinha._loadback(Xinha.pluginManifest[pluginName].url, callback, this, pluginName); 
    41334244    } 
    41344245    else 
  • trunk/XinhaEasy.js

    r1416 r1421  
    433433    for(var i = 0; i < load_plugins.length; i++) 
    434434    { 
    435       // Inc ase of [ 'Plugin1', ['Plugin1', 'Plugin3'] ] 
     435      // In case of { from: '/path/to/plugins', load: ['MootoolsFileManager'] } 
     436      if(typeof load_plugins[i] == 'object' && typeof load_plugins[i].from == 'string') 
     437      { 
     438        // Resolve the "load" into a list of plugins 
     439        var externs = parse_plugins(load_plugins[i].load); 
     440         
     441        // MPush them into plugins as external plugin objects 
     442        for(var ii = 0; ii < externs.length; ii++) 
     443        { 
     444          // In case you want to specify a non-default plugin file naming 
     445          if(externs[ii].match(/\//)) 
     446          { 
     447            xinha_plugins.push({ url: load_plugins[i].from + '/' + externs[ii] , plugin: externs[ii].replace(/.*\/([^.]+)\..*$/, '$1') }); 
     448          } 
     449          else 
     450          { 
     451            xinha_plugins.push({ url: load_plugins[i].from + '/' + externs[ii] + '/' + externs[ii] + '.js', plugin: externs[ii]}); 
     452          } 
     453        } 
     454        continue; 
     455      } 
     456       
     457      // External plugin definition 
     458      if(typeof load_plugins[i] == 'object' && typeof load_plugins[i].url == 'string') 
     459      { 
     460        xinha_plugins.push(load_plugins[i]); 
     461        continue; 
     462      } 
     463       
     464      // In case of [ 'Plugin1', ['Plugin1', 'Plugin3'] ] 
    436465      if(typeof load_plugins[i] != 'string') 
    437466      { 
  • trunk/examples/index.html

    r1409 r1421  
    77      <li><a href="Newbie.html">Xinha Complete Example (Best For Newbies)</a></li>  
    88      <li><a href="UsingPhpPlugins.php">Image Uploading and Link Browsing Demo (Requires PHP)</a></li>       
     9      <li><a href="CustomPlugins.html">Custom Plugins Example</a></li>       
    910    </ul> 
    1011     
Note: See TracChangeset for help on using the changeset viewer.