News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Package SDK, anyone?

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

Previous topic - Next topic

Kela

#120
Here is DTD for package-info.xml: http://www.simplemachines.org/xml/package-info
Here is DTD for install.xml: http://www.simplemachines.org/xml/modification

Anyone need something more?  ???
[nofollow]

B Patterson

QuoteThese 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.

If you're using a good editor, it's a simple Find & Replace in your code.  Find any "    " sets of spaces (or however denote an indent to you) and replace with a "\t" charcter, as long as its' between <![CDATA[]]> tags.  Edit Plus can do this, notepad++ can do this.  Not too difficult.

Chris Curran

bpat,

Thanks for the input, but you're not replying to what you quoted. The post you quoted concerns the very sticky issue of brace placement/indentation. It appears the doc crew has made some progress in this area since my post, so I won't comment further.

Regarding tabs... Yes, well, it's not that easy for a number of reasons. For starters, how to replace spaces with tabs isn't what I was asking - I know regex like the back of my hand. Literally - I wrote compilers for HP in the 80's. My "problem" was that a SMF source file I was working on had mixed spaces and tabs in the file - it wasn't consistent. It's the lack of consistency that caused the problem. I don't expect to have to load up a file in my editor (TSE) and have to start an editing session by replacing spaces with tabs. Who does?

Lastly, I don't care for tabs in source files. It causes all kinds of style problems. Try it - load up a SMF source and set your tabs to 4 - notice how rotten ugly everything is? SMF sources appear to be using a tab size of 8 - that's OK, but many programmers use different sizes and those who don't use 8 will have to guess around until they hit it on 8 all the time guessing at what it's supposed to look like (and it's not just about 8 or 4 - 5, 3 and 2 are also common values used for tab size). Now, if you're one of those non-8 folks, then you probably won't be making a permanent change to the default tab size in your editor. Lets presume you load up a file and forget to change the tab size of your editor (it's a 2000+ line mod, so it's very possible that you'll load up and not be anywhere near original SMF code to see that the tabs are not lining up). You start editing the source with your tabs set to 4, then save it out. The formatting of that file is now all screwed up. Tabs in general are a PITA, but if SMF wants tabs in the source, I'll play along.

cheers,
Chris

B Patterson

#123
I hear what you're saying.  And I understand.  Except that your argument doesn't hold water (well, the latter part).

The spaces vs. tabs in one file is an issue, and I agree with you there.

The other part about having 8,4,5,3,2 tab spacing messing up the code, that's wrong.  What is a tab character?  "\t".  So if it's a character, and each program can interpret it differently with 8,4,5,3, or 2 character spacing.  But, when it comes down to it your code essentially looks like:

[code]
function something($var) {
\tglobal $vars;

\tif(something != something_else) {
\t\techo 'I don\'t equal!!';
\t}
}


So the program interprets the "\t" character to be what it is and define a length.  So if you use whatever spacing you want, as long as the tabs aren't converted to spaces, it won't matter what tab-spacing you use to mod on.

I personally mod on a tab-spacing of 2.  I find it easier to read.  And yet every mod I've done works.  I use tabs, not spaces.  Both of my mods (although I have more) work perfectly fine.  It's just a matter of properly defining how many tabs there are, not how far indented it is.  You won't screw up the formatting of the file.  It should be program independent.[/code]

Dannii

There shouldn't be a mix of tabs and spaces in any of the SMF files (for indents, of course spaces are needed elsewhere). Where did you see the mix?
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Chris Curran

bpat,

Yea, it can mess things up. I'm off at a star party right now doing things like this: http://www.planetcurran.com/astro/camp-03.jpg

I didn't want you to think I was ignoring you. When I get back I'll reply in full...

cheers,
Chris

Chris Curran

Quote from: eldʌkaː on February 14, 2007, 11:37:02 PM
There shouldn't be a mix of tabs and spaces in any of the SMF files (for indents, of course spaces are needed elsewhere). Where did you see the mix?

I think it was Calendar.php but I can't swear to it right now. I'll touch base with you when I get back to clarify.

cheers,
Chris

Jack.R.Abbit™

all due respect but if you had paid attention to any of the existing source you were modifying you may have noticed that your style was different.  This should have taken place around line 10 or 20 of your mod... not at line 2000.  I personally dislike the style as well.  I dislike tabs... but I do switch my editor (Homesite) before I start.  I also dislike the {} on their own line because of the way they look... however, I do believe it makes it easier for mod writers to come along and alter the control statement, etc.  But the style is what it is... and that is the chosen style for SMF source.

BTW, I look forward to trying out your cal mod.  Repeating events is something that has been talked about for a long time... and attempted several times.  They never seem to see daylight.

Chris Curran

Jack,

Well, I don't completely disagree with you. Only partly. :) Yes, I could/should have caught that I was using a different coding style, but, I wasn't aware that there was a specified coding style wrt brace placement. However, when a project *requires* a certain style, IMHO, it should state that up front and not rely on any programmer to notice what style is being used and hope that they conform to it. I'm happy to use whatever style a project requires.

Tabs... and CR/LF.... I've been using the same editor since the mid eighties - QEdit then its later upgrade, TSE32 (The Semware Editor, 32 bit version). Working on SMF mods with my trusty old friend has been a real PITA and somewhat of a learning lesson. I've made some config changes to TSE that I think now bring me into conformance with SMF standards (it looks like SMF uses LF instead of CR/LF?).

A good bit of this is pent up frustration with the SMF mod dev process in general. I don't want to sound too critical because it appears that the doc crew is trying hard to get things right. Also, the mod approval process could use a revamp. Write a mod, post it and hope that someone looks at in some undetermined amount of time, and oh, btw, don't ask about the status of the mod approval or you get scolded and pushed to the bottom of the pile. The SMF mod approval process should be accountable - for *both* sides of the process.

I've gone back through my code and modified the offending braces and modified the repeating UI a bit. That has lead to another problem with testing of my mod (using test_modification.php). My current problem is this:


    <file name="$themedir/Post.template.php">
        <operation>
            <search position="replace"><![CDATA[
    // Now some javascript to hide the additional options on load...
    if (!empty($settings['additional_options_collapsable']) && !$context['show_additional_options'])
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapOptions();
        // ]]></script>';
]]></search>
            <add><![CDATA[
    // Now some javascript to hide the additional options on load...
    if (!empty($settings['additional_options_collapsable']) && !$context['show_additional_options'])
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapOptions();
        // ]]></script>';

    if ($context['event']['repeating']=='0')
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapEndDate(\'none\');
        // ]]></script>';
]]></add>
        </operation>

    </file>


The search phase fails. I have compared the org source file to my xml code using a hex viewer - they compare byte for byte. No missing tabs, spaces or LF's. Here is the error msg:



// Now some javascript to hide the additional options on load\.\.\.
if \(\!empty\(\$settings\['additional_options_collapsable'\]\) && \!\$context\['show_additional_options'\]\)
echo '
\\<\!-- // --\>\<\!\[CDATA\[
swapOptions\(\);
// \';
\]\]\>




Via the normal process of removal, I narrowed it down to this failing:


        ...snip...
        <operation>
            <search position="replace"><![CDATA[
        // ]]></script>';
]]></search>
        ...snip...


It doesn't seem to like having "// ]]></script>';" in the search clause. Note the error msg above too - the line after "swapOptions()". Is the "]]" from the </script> statement messing up the search engine?

cheers,
Chris

Rudolf

You can't nest CDATA tags.
The solution is to escape the closing ]]> for the CDATA of the Javascript code.
example of javascript code (In <add>, <search> and other tags):

<add><![CDATA[
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[

//some javascript code

// ]]>]]<![CDATA[></script>
]]></add>
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

JayBachatero

I've seen people do this.

        ...snip...
        <operation>
            <search position="replace"><![CDATA[
        // ]]' . '></script>';
]]></search>
        ...snip...

Concatenate the ] and >.
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(it looks like SMF uses LF instead of CR/LF?).
Yeah, I believe that it does. As far as I know, Windows is the only OS that likes using CR/LF, most others use just LF (with the exception of Mac, which uses just CR).
A good editor should transparently convert them (if the file uses LF, it uses LF. If the file uses CR/LF, it uses CR/LF). :)
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 Rudolf and Jay. I never got either form to work in a search clause. Ultimately I changed what I was looking for.

Regarding the [add] clause. In the Post.template.php section of my mod xml I had to resort to this:


    if ($context['event']['repeating']=='0')
        echo '
        &lt;script language="JavaScript" type="text/javascript"&gt;&lt;![CDATA[
            swapEndDate(\'none\');
        // ]]&gt;&lt;/script&gt';


I found this form here: http://www.simplemachines.org/community/index.php?topic=121862.0

When I tried either of the forms proposed by you guys, it seemed to lose the end-tag and it ran on until it got real weird (reporting that it couldn't find text in files that I wasn't looking in, etc - acting like a compiler does when it has a missing "}" somewhere in the middle of the source file). However, in the Calendar.template.php section of the mod xml, I used the following and it seems to work (Rudolf's I think):


  if ($context['event']['repeating']=='0')
      echo '
      <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
          swapEndDate(\'none\');
      // ]]>]]<![CDATA[></script>';


Very odd. Very odd indeed....

Chris Curran

Daniel,

You should re-read your post - it's sounds like a Monty Python routine! :) (that was a compliment). You should have worked on some of the Unix and proprietary systems that were floating around in the 70's and 80's - they used all sorts of EOL forms. Heck, even a few (e.g. Qantel) had no EOL char.

Now to the point of the post. Yes, any good editor can handle this, but that's not the question: What is the SMF standard regarding the line terminator? Personally, I edit php code on all three of the major platforms: Windows (CR/LF), Linux (LF) and OS/X (CR). Which form does SMF want?

cheers,
Chris

Joshua Dickerson

LF please. (I will add it to the coding guidelines, even though we don't check for it)
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Chris Curran

#135
Quote from: groundup on March 02, 2007, 11:30:05 PM
LF please. (I will add it to the coding guidelines, even though we don't check for it)

10-4. Note that Calendar.template.php has a mix of CR/LF and LF EOL formats.... There may be more files like this, but I found this one last night. BTW, the mix of EOL formats causes trouble for editors that detect what EOL format to use (based on file contents). It bit me without me even knowing about it (http://tinyurl.com/yvuly4).

38753970

I use PowerArchiver 2004... works like a charm  

The One

The problem is choice

ShadowDragon

Is it possible that the "type"-element (with attributes modification, avatar, language) is undefined under the namespace ???

The One

The problem is choice

Advertisement: