Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Nao
4381
Off-topic / Re: Doctor Who
« on September 30th, 2012, 12:32 AM »
So... Cliffhanger or not? Bearable or not?
4382
The Pub / Re: Language editing inside Wedge
« on September 29th, 2012, 10:51 PM »
Would it really make things simpler...? From what I can see, it would shorter one line by a few dozen bytes, that's all. Also, loadLanguage is only (a bit) slower when base_theme_dir is enabled, if you're not using the default theme. Because it comes after it in terms of priority...

So, basically, I think these would be the wrong reasons for removing support.
The good reasons would be: (1) I don't know a thing about this feature and don't even know if it's documented somewhere, (2) if I don't know about it and it's probably not documented, considering that whenever I need something implemented I do it myself, I guess I myself see no reason to support something that I don't either need or know about...

Really, do as you please!
4383
Features / Re: New revs
« on September 29th, 2012, 05:57 PM »
rev 1720 -- JS language strings! Thankfully there's a Revert button in case things go wrong... :P
(6 files, 7kb)

+ Added support for language caching inside JS files. Which, as you're going to see, can save a lot of bandwidth. Currently only applying it to the index template... (Subs-Cache.php, Load.php, index.template.php, script.js)

@ So, basically: just add a "@language index;" line somewhere in your JS file (if you need a language string in index.language.php), and then just use regular $txt['string'] right within your JS code. The string will always be escaped, so you don't need to surround it with quotes. If you need more language files, use "@language index, otherfile, ..." or use multiple @language keywords, your choice.

@ You can include plugin language files with "@language Author:Plugin:LanguageFile". The cache won't be flushed when they're modified, though, so you'll need to manually empty the JS cache folder. This is going to stay like that until Pete implements his planned 'language delta' feature.

! Fixed a minor error that is more a PHP bug than a Wedge bug to me... If you do strpos($string, $number), you'll apparently always get false even if $string does contain a string representation of $number. Anyway, that made cache flushing problematic in Wedge. (Subs-Cache.php)

* Casenazi. (PersonalMessage.language.php)
4384
The Pub / Re: Language editing inside Wedge
« on September 29th, 2012, 03:57 PM »
As I said before. This file date business is temp stuff. I'm planning to get rid of it as soon as you implement language file caching.
But until this is done, I have to do it... And checking for the file date of two folders (one when default theme is used) once per page load is quite fast really... The only issue being with windows and still.
4385
The Pub / Re: Language editing inside Wedge
« on September 29th, 2012, 01:09 PM »
Before we start worrying about no supporting devs to author plugins, we should worry about the fact that no other dev has offered their help for the core dev at this point... :p

Not that it bothers me, though. But some days, I'd certainly like for emanuele to join us... He reminds me of my enthusiasm when we started work on Wedge ;) Plus he does some good and nicely formatted code. (Following SMF standards is important to me.) But right now he's SMF 2.1's main contributor so I'm not even going to bother asking...

So, I'm thinking of committing my language code 'as is'... (1) it's an alpha, (2) if you really need to update your script files and it doesn't work (e.g. you're working locally or your server's filesystem disabled last modified dates on folders) then you can always just empty the js cache folder manually, (3) gosh, it's an alpha! If Pete implements language deltas, then we'll be fine by the next beta!
4386
The Pub / Re: Language editing inside Wedge
« on September 29th, 2012, 12:06 PM »
Quote from PantsManUK on September 29th, 2012, 11:56 AM
Interested observer here... Are you saying that for the *ENTIRE* lifetime of the product (however long that's going to be) you're *NEVER* going to add new strings to the base installation, because that's what your quoted text seems to suggest...?
No... I think what Pete means, is that since Wedge is going to be provided on the basis that "new updates are simply by dropping the updated files", the goal is for users not to have to modify their files manually.
So, you should understand this as: we're going to update the language files -- and we're going to be the only ones who can do it.

I'm guessing if you want to add your own language strings, manually and all, you can always use Custom.language.php... (Which I'm not even sure is a feature in Wedge?!)

Regarding the cache, so... I've finished implementing the filemdate check, and unfortunately it's not as solid as I thought. It should work properly on a Linux server, but when it comes to my Wamp install, my last modification date for the languages folder dates back to my last SVN update on it, rather than my last file change inside the folder... So it means it's going to work on a regular install, but not on my local install. Bugger! Now how do I deal with this... Is it a Windows bug? The php.net page on filemtime doesn't mention it...
4387
The Pub / Re: Language editing inside Wedge
« on September 29th, 2012, 11:34 AM »
When I say 'test for file changes', I obviously say 'call filemdate on the file and compare it with $latest_date'... Should I re-explain everything again..?? :-/
Posted: September 29th, 2012, 07:59 AM

Also -- my bad: script files take the current theme into account... The theme's folder name is included in the file ID.
Posted: September 29th, 2012, 11:22 AM

The only 'way' I can see to quickly test whether we should check language file dates is...

if (filemtime($theme['theme_dir'] . '/languages/.') > $settings['latest_lang'])

('latest_lang' being an hypothetical variable where we store the most recent language file date.)

This could be done in Load.php at some point. If the language folder is updated, then we can either: (1) clean_cache('js') entirely (wanna say, *who minds*), (2) go through all files and test for their dates etc... (booooring!), (3) clean_cache('js') but only on files that use $txt strings in them. (A bit boring, too, especially since I'm going to be using $txt everywhere at that point...)

Two problems remain:
1/ should we store a latest_lang variable for each and every single language folder available to us..?
2/ how do we keep track of language files for plugins..?

Welcoming ideas, as always... :) Especially since this is probably the last remaining step before I can commit my work. (Which is already 3 times bigger than the original working code from a few days ago :P)
4388
The Pub / Re: Language editing inside Wedge
« on September 28th, 2012, 11:52 PM »
Just to keep you posted...

- Fixed a surprising bug where strpos($del, $latest_date) would return false even if $latest_date was in $del... Because it was an integer. I thought PHP did some typecasting before a strpos, but apparently not...! So it means that this caching feature was pretty much broken since the beginning...
- The code doesn't (yet???) support (or care for) other themes. I figure you'll want to add support yourself :)
- Finished implementing per-language caching, i.e. generating 'script-french' and 'script' files depending on your language.
- Added support for plugin language files.
- Added a $settings['js_lang'] array. It is serialized in a similar fashion to $settings['registered_hooks'], which I'm not super-happy about, but it's still fast enough I guess. 'js_lang' is unserialized to an array of serialized arrays, so basically it looks like this in the end: array('script-' => array('index, Arantor:ThemeSelector:SkinSelector')) (<== SkinSelector being the language file inside the ThemeSelector plugin.)
- 'js_lang' is supposed to help in two ways: (1) if the script ID is missing from the array, it means there are no languages to be included, so we can directly include 'script-1234.js.gz' instead of adding the language string. (2) Supposedly, when we do loadLanguage, we can first test for file changes (I'm not recording this yet...), then if changed, go through js_lang and remove all JS files that use our language file.

As indicated in an earlier post, the main issue with js_lang is that it makes it impossible to test for changes to a file like 'JS.french.php' if the file is never loaded otherwise. I'd recommend maintaining a database of changed files somewhere, and then checking for changes before doing the wedge_cache_js test/call.
So... What do we do?
4389
Features / Re: New revs
« on September 27th, 2012, 09:37 PM »
rev 1719
(2 files, 3kb)

! Fixed broken install process. (install.php)

! Fixed broken satellite CSS files -- they were compiled incorrectly because they no longer automatically include virtuals. (Class-CSS.php)
4390
Features / Re: New revs - Public comments
« on September 26th, 2012, 09:05 PM »
So what's the resulting output?
4391
Features / Re: New revs - Public comments
« on September 26th, 2012, 07:59 PM »
I tested my code through a file() call, and it seems to work just fine... (Phew.)
4392
Features / Re: New revs - Public comments
« on September 26th, 2012, 03:57 PM »
Quote from Arantor on September 26th, 2012, 03:32 AM
Yeah, I knew about that, but I wasn't sure if I could actually pay myself even in the sandbox.
That's the whole point of the sandbox, actually... :)
Quote
Also, the installation is currently completed broken. Moving that if() test around in Settings.php breaks the installer, because the installer now repeatedly and consistently removes the if() and the opening { of that test.
Hmm, it's odd, did it work earlier...? Because it looks like those lines were already broken before I did my Settings.php change.. Anyway, line 1836, replace with:

Code: [Select]
// Remove the redirect (5 lines of code)...
if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 4]) == '}')
{
for ($j = $i + 5; $i < $j;)
$settingsArray[$i++] = '';
continue;
}

This is untested but it should work... (I'll be cooking up an even better version later today, that doesn't care about the length.)
Quote
And on a fresh install, it always seems to me that jQuery can't be loaded from Google. This has never once worked for me on any test install I've ever made, including localhost.
I've never had such any problem...?!
What's in your HTML head?
Quote
Also, I have no idea how the sandbox works, especially since it doesn't seem to handle subscription payments. It seems to be geared for much larger and more complex stuff that we're trying to do.
Ah, sorry, can't help... :(
Posted: September 26th, 2012, 03:47 PM

What about this one btw..?

Code: [Select]
// Remove the redirect (normally 5 lines of code)...
if (strpos($settingsArray[$i], 'file_exists') !== false && trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))')
{
$settingsArray[$i++] = '';
$tab = substr($settingsArray[$i], 0, strpos($settingsArray[$i], '{')); // It should normally be empty.
while ($i < $n - 1 && rtrim($settingsArray[$i]) != $tab . '}')
$settingsArray[$i++] = '';
$settingsArray[$i] = '';
continue;
}

--> basically, it just records the level of the first curly (so that we can find its closer easily), then it removes everything before the closer. (Also, the last $i call should ensure it doesn't increase it again because it's done through the for() loop... Oops.)
4393
The Pub / Re: Language editing inside Wedge
« on September 25th, 2012, 10:28 PM »
So if it were up to you. When it comes to js language caching, what would you store in the db and where in the code would you check on updates being needed or not?
4394
The Pub / Re: Language editing inside Wedge
« on September 25th, 2012, 03:55 PM »
Quote from Arantor on September 25th, 2012, 02:24 PM
Well, there's one very large problem to contend with: what happens if a theme (not a skin) decides to have its own language files?
Well, it goes through loadLanguage all the same, doesn't it..? And loadLanguage is the perfect place to monitor changes... Heck, I just checked -- it even does a file_exists on any language file you're going to load, meaning that the file stats are cached from that point on, meaning you can get the filemtime for free, meaning doing a check there is a no-brainer.
Of course it means that if you have a special JS file like JS.english.php that you only load for JS caching, it'll never be seen as out of date. Thus we could have some additional cache check somewhere else... (e.g. in add_js_file)
Quote
Though I'm tempted to remove base_theme support, I don't believe anyone except Bloc ever used it and even then I'm not entirely sure about that. But I don't see that we can remove actual support for alternate themes in general.
I don't know what base_theme is, but what I know is that I've never delved into alternate themes, had a few back in the day but now it's default only... I wouldn't know where it slows Wedge down, really. (Although there's quite a lot of code for alternate theme language files in loadLanguage...)
Quote
that will need to be factored in, which means potentially you need to include the theme id in the cached filename.
Hmm, yeah, I guess so...
Wess/Subs-Cache aren't tested for alternate themes anyway. I mean, it's pretty much as if theme support was broken/removed for me. For instance, if you have a 'Wine' folder in your alternate theme, the CSS cache will much certainly save its files in the same folders as the default theme's...

Anyway.
4395
The Pub / Re: Language editing inside Wedge
« on September 25th, 2012, 12:22 PM »
Quote from Arantor on September 24th, 2012, 12:38 PM
2) We update a core language file which is used by multiple plugins of indeterminate use. Like above, short of checking every plugin, we can't really do a lot. Which means, we're either looking into caching the last update by language file as you suggested, or we clear the JS cache.
Clearing the JS cache really isn't much of a big deal... Packer is an efficient piece of software, it's only slow when you try using it in real time obviously. The only 'big' chunk of code in Wedge is the jQuery library, and even that is never going to be packed manually (that's why I added the <jquery_cache> tags around the local copy of it. So that it's ignored by Packer later.)
Quote
The problem with clearing the JS cache is that of course it means the next page load is going to hurt for someone.
One person is going to have a one-second delay in their page load... That's pretty much all. And that person is likely to be the admin, testing their own changes.
Quote
Would it not be better to purge the cache but *immediately* rebuild the files you know you're going to need for definite?
In any case you're going to rebuild the files while loading a page, so I don't see the point in rebuilding a selection of pages when the cache is purged, or when the next user requests the cached files...

Well, now I think the best way to deal with the cache purge for now would be to cache an array of key/values where key is the requested script file, and values is the list of language files needed. We can easily maintain that list when rebuilding the JS cache: if the file list has changed, then we update the database values. This saves us: (1) the need to go through the original JS files to retrieve a list of language files to test (this way, if we want to test whether a file needs to be rebuilt, we can directly test the JS filedate and then the language filedates and take the most recent of all.) (2) the need to search for 'script-french-1234.js.gz' if we know that a particular file doesn't have language entries, in which case we can directly look for 'script-1234.js.gz'.

BTW, my code only supports loadLanguage for now... You'll have to build loadPluginLanguage into it if you want. :)