News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Package SDK, anyone?

Started by [Unknown], November 22, 2004, 03:26:37 AM

Previous topic - Next topic

BlueSteel

Hi,

I have done some modifications to my site.. and would like to try to find a utility to do 2 thing
1. Compare the files/Dirs
2. create a mod install file
2a. when parsing the differences ask me if i'd like to add each difference into the mod creation file

I think that this type of utility would be very benificial to those who make changes to their sites and then update their site to use a newer version of SMF or mod that may wipe out their existing changes..

I'd really hate to have to manually compare the files (using a compare utrility then have to go and manually create / copy / paste the original code from the original file and the same from the edited file and then work out and type in the correct syntaxes to do the search and replace/add/ delete  To me this seems like something that could be automated

But i can't find a tool to do this.. is there such a tool.. if not why not .. LOL

0897jhPEFUOIyG90

#101
BlueSteel,

Try the following:

http://www.gnu.org/software/diffutils/diffutils.html [nofollow]

Or for windows:

http://gnuwin32.sourceforge.net/packages/diffutils.htm [nofollow]

or

http://www.grigsoft.com/download-windiff.htm [nofollow]

edit: whoops, I just re-read your post and realised you are probably already aware of such tools, and were asking for an automated mod package generator, which would be a brilliant idea, just a pain to create.

Though Diff and Patch could achieve the desired effect, just outside the SMF package manager:

http://www.gnu.org/software/patch/patch.html [nofollow]
http://gnuwin32.sourceforge.net/packages/patch.htm [nofollow]

Gobo

does the SMF mod creator work with 1.1.1 and is it recommended by the team?

http://sourceforge.net/projects/smfmc/

aku

JayBachatero

Yea I recommend it.  I've used it in the past.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

BlueSteel

Can someone please post a tutorial on how to use it.. lol.. Thanks in advance

Gobo

#105
thanks

ill try it out now

blue steel it simply creates the XML files for you and then u have to package it up from what I can see

u pick the type of modification u want to make
search for text
replace or add after or before text
and so on and so forth

Also this makes things EASIER for u to do - it dosent generate code by itself - so u have to know what ur doing

Chris Curran

I'm working on a mod package that provides repeating events to the calendar. My mods are passing the test_modifications.php tests, except for one. Below is the code from modifications.xml that is causing the trouble:

    <file name="$sourcedir/Calendar.php">
        <operation>
            <search position="replace"><![CDATA[
                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "'
]]></search>
            <add><![CDATA[
                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $end_time) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "',
                    repeating = '" . htmlspecialchars($_REQUEST['repeating'], ENT_QUOTES) . "',
                    repeat1_parm1 = '" . htmlspecialchars($_REQUEST['repeat1_parm1'], ENT_QUOTES) . "',
                    repeat1_parm2 = '" . htmlspecialchars($_REQUEST['repeat1_parm2'], ENT_QUOTES) . "',
                    repeat2_parm1 = '" . htmlspecialchars($_REQUEST['repeat2_parm1'], ENT_QUOTES) . "',
                    repeat2_parm2 = '" . htmlspecialchars($_REQUEST['repeat2_parm2'], ENT_QUOTES) . "',
                    repeat2_parm3 = '" . htmlspecialchars($_REQUEST['repeat2_parm3'], ENT_QUOTES) . "',
                    repeat_end_type = '" . htmlspecialchars($_REQUEST['repeat_end_type'], ENT_QUOTES) . "'
]]></add>
        </operation>
</file>


When I run the test on this, I'm told that the search text cannot be found, however, I have cut & pastes the search text directly from the original source file, so, how could it be that it cannot be found? I've gone over this a few hundred times, so I obviously can't see the trees for the forest at this point. Anyone have an idea what's going on here?

tia,
Chris Curran

niko

I think problem is blank line

Try modifying it to like: (Don't copy from here because I think tabs are replaced by spaces)

<![CDATA[                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "']]></search>
Websites: Madjoki || (2 links retracted by team, links out of date and taken over.)
Mods: SMF Arcade, Related topics, SMF Project Tools, Post History

WIP Mods: Bittorrent Tracker || SMF Wiki

Chris Curran

Thanks, but that's not it. I've got dozens of other mods formatted the same way (i.e. blank lines) that seem to work perfectly (I did try it just to be 101% sure though). I'm wondering if there isn't a special char that's botching up the search engine in there...

Quote from: Niko on February 02, 2007, 02:10:59 PM
I think problem is blank line

Try modifying it to like: (Don't copy from here because I think tabs are replaced by spaces)

<![CDATA[                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "']]></search>


Chris Curran

I found the problem; Calendar.php has tabs embedded in it....

Quote from: Chris Curran on February 02, 2007, 02:13:47 PM
Thanks, but that's not it. I've got dozens of other mods formatted the same way (i.e. blank lines) that seem to work perfectly (I did try it just to be 101% sure though). I'm wondering if there isn't a special char that's botching up the search engine in there...


Chris Curran

OK, I've got the basic mod package for repeating Calendar events working and installing to a clean system without errors. Now, I need to be able to modify the Calendar table structure and create another table; should I do that with an external script, or is there a better mechanism for that?

thanks,
Chris Curran

Daniel15

#111
Quote from: Chris Curran on February 02, 2007, 04:52:44 PM
OK, I've got the basic mod package for repeating Calendar events working and installing to a clean system without errors. Now, I need to be able to modify the Calendar table structure and create another table; should I do that with an external script, or is there a better mechanism for that?

thanks,
Chris Curran

An external script, ran via a <code> tag in the package-info.xml file.
A basic script:

<?php
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

// Your queries here
?>



As an example, a query to add a table:

// Shop items table
db_query("
CREATE TABLE IF NOT EXISTS {$db_prefix}shop_items (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`desc` TEXT NOT NULL,
`price` DECIMAL(8,2) UNSIGNED NOT NULL,
`module` TINYTEXT NOT NULL,
`stock` SMALLINT NOT NULL,
`info1` TEXT NOT NULL,
`info2` TEXT NOT NULL,
`info3` TEXT NOT NULL,
`info4` TEXT NOT NULL,
`input_needed` TINYINT UNSIGNED DEFAULT '1' NOT NULL,
`can_use_item` TINYINT UNSIGNED DEFAULT '1' NOT NULL,
`delete_after_use` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL,
`image` TINYTEXT NOT NULL,
`category` SMALLINT NOT NULL,
PRIMARY KEY (`id`)
)", __FILE__, __LINE__);


And a query to modify add a column to a table, if it doesn't already exist:

//add money columns to members table, if they don't already exist
$result = db_query("SHOW COLUMNS FROM {$db_prefix}members LIKE 'money'", __FILE__, __LINE__);
if (mysql_num_rows($result) == 0)
db_query("ALTER TABLE {$db_prefix}members ADD `money` DECIMAL(9, 2) UNSIGNED DEFAULT '0.00' NOT NULL", __FILE__, __LINE__);
mysql_free_result($result);


Make sure the queries do NOT have a semicolon ( ; ) on the end, otherwise your script will die with a "Hacking attempt..." message. Additionally, do not put the database name in backticks (eg. `{$db_prefix}members`), or you'll get an "Invalid Database Name ''" message when running the script by itself (SSI.php already adds the backticks).
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Chris Curran

Thanks Daniel! Worked like a charm.....

Chris Curran

Quote from: Chris Curran on February 02, 2007, 04:18:40 PM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris

niko

SMF uses tab indentation. Check from settings of your program that it uses tabs instead of spaces.
Websites: Madjoki || (2 links retracted by team, links out of date and taken over.)
Mods: SMF Arcade, Related topics, SMF Project Tools, Post History

WIP Mods: Bittorrent Tracker || SMF Wiki

Chris Curran

The settings that are added via 'add_settings.php'. Where do they show up at on the screen for user input (e.g. to turn an option on/off)?

thanks,
Chris

Chris Curran

Never mind... I found ModSettings.php. Geez, doc crew, could you have hid that info any better?

Quote from: Chris Curran on February 03, 2007, 04:55:04 PM
The settings that are added via 'add_settings.php'. Where do they show up at on the screen for user input (e.g. to turn an option on/off)?

thanks,
Chris

JayBachatero

Quote from: Chris Curran on February 03, 2007, 11:46:59 AM
Quote from: Chris Curran on February 02, 2007, 04:18:40 PM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris
It is strongly recommended that you use tabs (\t) in your source files.  Also use the BSD/Allman Style for indentation as well.  Not K&R style.
http://en.wikipedia.org/wiki/Indent_style
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Daniel15

Quote from: JayBachatero on February 03, 2007, 10:23:24 PM
Quote from: Chris Curran on February 03, 2007, 11:46:59 AM
Quote from: Chris Curran on February 02, 2007, 04:18:40 PM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris
It is strongly recommended that you use tabs (\t) in your source files.  Also use the BSD/Allman Style for indentation as well.  Not K&R style.
http://en.wikipedia.org/wiki/Indent_style
The full guidelines are available at http://custom.simplemachines.org/mods/guidelines.php :)

QuoteNever mind... I found ModSettings.php. Geez, doc crew, could you have hid that info any better?
I agree, we need more developer documentation...We'll try to work on some in the near future :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Chris Curran

Quote
The full guidelines are available at http://custom.simplemachines.org/mods/guidelines.php :)

Excuse me? I have been using what little doc there is posted here: http://custom.simplemachines.org/mods/

When I click on "Coding Guidelines" I am taken here: http://docs.simplemachines.org/index.php?topic=218

These are the coding guidelines I used, and for anyone to come in now and say there is another set of guidelines that isn't shown to anyone until AFTER the code is written is, well, it's BS. I've been using K&R indentation almost 30 years. Aside from BSD/Allman being a horrible waste of space, why isn't this coding style request documented out front where people will see it BEFORE they submit 2000+ line mods??? Hey, I have an idea! Why not put the docs and coding style requirements in the SDK like a real SDK should have.... Lame. Real lame.


Advertisement: