1
jegelstaff
Perl script for cloning WF-Channel

Hi all,

My company really likes the WF-Channel module. It's got the simplicity of something like TinyContent/TinyD, but it's got the group permissions structure that more heavy duty modules have too. Basically it's a great way to embed HTML pages in a XOOPS site when you aren't looking for article management and just want the content up there on the screen.

But there is one big problem: You can't have more than one Main Menu entry; all your pages are part of the same series of pages. For example, you can't have some pages that are part of a section called "How to use this site" and have some other pages that are part of a different section called "Information About Giaks"

The solution would be to clone the module. But that takes some time and care, right? All that file renaming and search and replace operations in multiple files....

Enter clone.pl

clone.pl is a simple little perl script that will make a copy of the wfchannel module that is ready to be uploaded to your server and run as a separate module from any other copy of wfchannel that you might have running already.

You can grab a copy of the script here: (right-click and select Save link target)
http://www.freeformsolutions.ca/clone.pl

Here's how to use it (there are a few things that you have to get right or else it won't work).

1. Make a copy of the wfchannel folder on your local computer (the idea is the modify this copy and then upload it to your server).

2. Rename the copy of the wfchannel folder that you just made. Don't forget what you renamed it to!

3. Put a copy of clone.pl inside the renamed wfchannel folder you just made.

4. Run clone.pl with two command line arguments. The first argument is the name of the folder (it must be the exact name of the folder), the second is a human-readable form of the module name. For example:

perl clone.pl aboutus "About Us"

5. If all goes according to plan, you'll get a message like this: "Cloning complete. About Us module ready for upload."

That's it. Upload the new module and install it and away you go. Don't forget to CHMOD the permissions on the folders that require that, as per the wfchannel readme.

If you have any questions or run into trouble, please reply to this post. Thanks and good luck!

--Julian

============

Notes:

This script was written using ActivePerl for Windows. I think it will run okay on Linux, but I can't say for sure. If you have problems, it's probably related to the syntax for the paths to files, which should be easy enough to modify and fix.

If you want to run this on a Windows computer and aren't sure how, get a copy of ActivePerl here:
http://www.activestate.com/Products/ActivePerl/

Install that and then you will be able to run perl scripts from a DOS Prompt box (not sure how that works on XP, sorry).

This script is meant to be run from the new folder you make. I believe if you run it from another location, the paths will be screwed up, depending on your operating system, version of perl, etc. What this means is, make sure the new folder that you made is the active folder when you run the script, ie: if the folder you made is called c:\xoops\modules\aboutus then make sure the DOS prompt is c:\xoops\modules\aboutus> when you run the script.

Or to put it another way, this is good:

c:\xoops\modules\aboutus>perl clone.pl aboutus "About Us"

While this is bad:

c:\>perl c:\xoops\modules\aboutus\clone.pl aboutus "About Us"

This script does not do anything with the upgrade folder since the idea is that you're starting a new wfchannel module from scratch.

Of course, make sure that your new folder name has no spaces!

The admin icon for the module looks exactly like the wfchannel icon, and says wfchannel on it. Not much a perl script can do about that (without all kinds of extra work), but the module name does change to reflect the human readable name you pass in at the command line so that makes it a little easier to tell your different copies apart.

To make a new icon, get a copy of the Bit3 font that is used for the XOOPS module icon text (or if you don't care about it matching, use any old font), and open up the .png file that contains the icon and edit it.

2
jegelstaff
Re: Perl script for cloning WF-Channel
  • 2004/10/21 19:12

  • jegelstaff

  • Module Developer

  • Posts: 518

  • Since: 2004/7/2 2


FYI: the script has been updated to make a few more changes in the cloned copy -- change name of sql file, and names of the search and comment functions. Renaming the search function is actually necessary in order to avoid a fatal error on the userinfo.php page of your site. So on the off chance that anyone has grabbed a copy of this and used it, we highly recommend manually making these new changes, or starting over.

--Julian

3
usera
Re:Perl script for cloning WF-Channel
  • 2004/10/23 10:42

  • usera

  • Just popping in

  • Posts: 29

  • Since: 2004/8/28


is it possible to edit your perl script to use for other modules for xoops? It would serve as a multipurpose tool

4
jegelstaff
Re:Perl script for cloning WF-Channel
  • 2004/10/23 17:50

  • jegelstaff

  • Module Developer

  • Posts: 518

  • Since: 2004/7/2 2


Sure, anyone can hack up something like this fairly easily, and if someone wants to use this script as a starting point for a similar script for another module, go right ahead.

For anyone attempting this kind of thing, here's the basic structure of the code (though it's so simple, anyone should be able to figure it all out):

1. Grab the command line arguments

2. Setup the variables you need for changing text later on (the names of the template files, etc)

3. Open up the xoops_version.php file and put the contents in a string.

4. Do a series of search and replace operations based on the new names. This is the part that will be unique for each module of course; what you search for will be different.

5. Overwrite the file with the new text you just searched and replaced on.

6. Repeat 3 to 5 for all files in the module that need changing. That's the other part that will be unique for each module -- the number of files that you have the do operations on, and what changes you have to make in them.

7. Rename any files that need renaming. Another unique operation.

They way WF-Channel is cloned here should be a good guide. Here's a good overview of what's required to clone a module:

https://xoops.org/modules/news/article.php?storyid=1714

Good luck!

--Julian

5
hawkeyegop
Re:Perl script for cloning WF-Channel
  • 2005/1/4 20:09

  • hawkeyegop

  • Just popping in

  • Posts: 83

  • Since: 2004/9/18


Could anyone give me pointers on this? I don't even really know what to do. I was going to download that program thing, but it was a weird file extension and I wasn't sure how to proceed.

Thanks

6
Bender
Re:Perl script for cloning WF-Channel
  • 2005/1/4 20:16

  • Bender

  • Home away from home

  • Posts: 1899

  • Since: 2003/3/10


Quote:

hawkeyegop wrote:
Could anyone give me pointers on this? I don't even really know what to do. I was going to download that program thing, but it was a weird file extension and I wasn't sure how to proceed.

Thanks


Uhh you read the first posting completely?

As in that post beginning under "Notes" jegelstaff explained what you need to run that "weird" file extension. (which stands actually just a perl script)

7
hawkeyegop
Re:Perl script for cloning WF-Channel
  • 2005/1/4 21:00

  • hawkeyegop

  • Just popping in

  • Posts: 83

  • Since: 2004/9/18


I did read that first post, and downloaded the Perl script. I was referring to his next post, where he mentioned some Windows program or something.

I have the Perl script but don't know what to do with it, that is what I'm saying.

Thanks,

Chris

8
hawkeyegop
Re:Perl script for cloning WF-Channel
  • 2005/1/4 22:57

  • hawkeyegop

  • Just popping in

  • Posts: 83

  • Since: 2004/9/18


OK, I guess that worked. THanks a lot!

Now if I was smart enought I would write something like this. But I don't understand how thing works at all!

Chris

9
jegelstaff
Re:Perl script for cloning WF-Channel

So I take it you got it working?

Basically, download ActiveState Perl and install it on your windows machine.

Then put the WF-Channel files and the script in a new folder as described above.

Then run the script from the DOS box as described above.

And if you got the message saying the new module was ready, then you should be good to go.

Good luck,

--Julian

P.S. About how it works...it's actually a very, very simple script, as far as Perl scripts go. All it does is grab the command line arguments that you pass it (the new name you want for the module) and then does a whole bunch of find and replace operations on the files in the wf-channel module.

Perl is a programming language that is very well suited to text file manipulation (and was the scripting language of choice before PHP came along). Many still swear by Perl though, the programmer's "swiss army knife" it has been called.

The ActiveState program is simply the environment you need installed to make Perl work (on windows). The .pl script is just plain text and you need to have ActiveState in order for your computer to be able to read the file and know what to do.

It's kind of like how you need a web server with PHP installed for your PHP files to be read and interpreted correctly. Perl is a programming language just like PHP.

10
jegelstaff
Re:Perl script for cloning WF-Channel

Quote:

jegelstaff wrote:
Sure, anyone can hack up something like this fairly easily,


I should say, anyone who knows a bit of Perl can!

I didn't mean to imply that anyone should be able to do this, and if you can't, then there's something wrong. There is defintely a little specialized knowledge at work.

--Julian

Login

Who's Online

367 user(s) are online (285 user(s) are browsing Support Forums)


Members: 0


Guests: 367


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits