vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Administrative and Maintenance Tools - Automatic Template Compiler (https://vborg.vbsupport.ru/showthread.php?t=170361)

Adrian Schneider 02-12-2008 10:00 PM

Automatic Template Compiler
 
Development Tool: Automatic Template Compiler
Requirements: PHP 5, vBulletin 3.5+

Summary: Allows you to edit HTML files directly instead of using the AdminCP template editor. ATC will automatically update the database if any changes are detected. This is intended for a development environment only, and will only run while in debug mode.

Why: Template development is a huge PITA because of how templates are stored in the database - they are compiled. This means you cannot simply save a file, or update the database, because vBulletin needs to compile them first, and maybe even update the style cache. This saves TONS of time copy pasting and switching between your editor, your page, and the vBulletin template editor box.

How it works: ATC maintains a checksum (md5 hash) of each template body, and when it finds that one is out of sync with your working copy, it will save that template automatically in a very efficient manner. It updates both the template about to be displayed in memory and also the real copy in the database.

It also includes a very basic import utility so you can copy your existing templates into the filesystem for easy editing.

How to use it: Follow the install instructions, and then whenever you edit a file, the changes will transfer to vBulletin itself.

This was written in PHP 5 (OO) and I have no plans to make it work with PHP 4, but I may eventually build an interface to manage the settings, but for developers, configuring it should be no problem. :cool:

cheesegrits 02-13-2008 02:27 AM

Works like a charm. No more template editor, yay!

Don't know what took you so long though. You told me about the idea around 7pm, and it was gone 10pm before you were done. You're getting slow in your old age.

-- hugh

TECK 02-13-2008 02:39 AM

Nice one, AJ. Will use it for sure.

Michael Biddle 02-13-2008 03:05 AM

Installed :D.

Great Mod Aj

Basboss 02-13-2008 04:54 AM

Installed.

Thanks dude.

testebr 02-13-2008 06:06 AM

Let me kiss your ass please!!!

nix 02-13-2008 06:25 AM

Nice :)

Now if you can learn to cook a can of soup as well as you code... ;)

Magnumutz 02-13-2008 06:41 AM

Let me get this straight... this makes a HTML copy of the template so you can edit it, without using the AdminCP or what?

Adrian Schneider 02-13-2008 07:50 AM

Quote:

Originally Posted by cheesegrits (Post 1441915)
Works like a charm. No more template editor, yay!

Don't know what took you so long though. You told me about the idea around 7pm, and it was gone 10pm before you were done. You're getting slow in your old age.

-- hugh

Well, 3 hours well spent I hope!

Quote:

Originally Posted by testebr (Post 1441987)
Let me kiss your ass please!!!

:erm:

Quote:

Originally Posted by nix (Post 1441988)
Nice :)

Now if you can learn to cook a can of soup as well as you code... ;)

Hey, lay off on the soup thing. I managed to cook alphagetti today without any incidents.

Quote:

Originally Posted by Magnumutz (Post 1441997)
Let me get this straight... this makes a HTML copy of the template so you can edit it, without using the AdminCP or what?

Right. Imports from DB to filesystem, and then watches the files for any changes, compiling and saving when they are found.

Cybertims 02-13-2008 08:13 AM

I dont quite get this, I have installed it, now what do I do?

Cheers

projectego 02-13-2008 08:27 AM

/me clicks install. Thanks!

Magnumutz 02-13-2008 10:11 AM

That's awesome... i might try it on the future.
Good job Adrian !

Boofo 02-13-2008 10:49 AM

I sure wish you guys weren't PHP 4 haters. ;)

Magnumutz 02-13-2008 11:33 AM

Ah crap... hope my host upgrades to PHP5... actually i'll make it upgrade :D

waza 02-13-2008 01:17 PM

you say you need to put ?do=atc_import as a variable on a page to import existing templates, but don't you mean ?do=import ?
however, thanks for this good time-saver

cheesegrits 02-13-2008 02:46 PM

Quote:

Originally Posted by Boofo (Post 1442076)
I sure wish you guys weren't PHP 4 haters. ;)

Someone has to be, otherwise we'll still be having this discussion when PHP20 comes out. PHP4 is a dead language. It has been officially "end of lifed" since the end of last year.

It's time we started exerting pressure as a community on all those hosting companies who refuse to upgrade, by voting with our feet. There are plenty of good hosts who do provide PHP5, and would be more than happy to take your business.

However, in this case the usual excuse that "my host doesn't support it" doesn't fly, as this tool is purely for use on local development machines, where it is up to you what version you run. Even if you still need to code to PHP4 standards, there's no reason you can't run PHP5. Just don't use any of the new features in your code.

If you have to have PHP4 available for testing, just run XAMPP, which has a neat little button that lets you switch between 4 and 5.

-- hugh

cheesegrits 02-13-2008 04:36 PM

AJ,

Can you do me a favor and move the config out of the plugin? Even if it's just a simple ACP option with stuff like:

myprojectid;1.0.2
anotherproduct;2.1.1

... and modify the plugin to grab that data and import / export any listed products.

At the moment, whenever we update your product, we lose any config data in the plugin. And lets face it, you do so like to rewrite and update your code. ;)

Speaking of updating, how about also adding the help and version URL's in the product?

-- hugh

waza 02-13-2008 08:30 PM

hmm, if i edit a template (file) and save it and refresh my page it shows the changes.
But if I refresh my page again, they are gone...

Edit: i found the problem: he saved it in another style than the style i was working in.

Adrian Schneider 02-13-2008 08:38 PM

Quote:

Originally Posted by waza (Post 1442500)
hmm, if i edit a template (file) and save it and refresh my page it shows the changes.
But if I refresh my page again, they are gone...

You'll have to PM me login details to try and debug that one. Try rebuilding your styles to see if that fixes it (does you no good, but narrows it down for me).

I'm about to upload an updated version where the config is moved into options.

cheesegrits 02-14-2008 02:10 AM

Quote:

Originally Posted by waza (Post 1442500)
Edit: i found the problem: he saved it in another style than the style i was working in.

I'm testing the new version Aj mentioned. As well as moving the config into an ACP option, I also bullied him adding configurable style-ids per product for import and export. So that will solve your problem.

-- hugh

Adrian Schneider 02-14-2008 02:49 AM

What he said.

Right now it defaults to the MASTER STYLE (-1) which is really what you should be using for any development, but I'm sure some of you are stubborn and will use it for customizing templates too. :)

I'll have the updated version uploaded within a few hours.

Appletalk 02-14-2008 10:05 AM

The PHP5 restriction is so lame!

kafi 02-14-2008 10:35 AM

This sounds like a great tool, I am mad when I edit templates and play with css - copy and pass circle

THANK YOU SIR!!! Will test it with next template changes .-)

Kirk Y 02-14-2008 11:38 PM

You're my hero Adrian! I was just ranting to a buddy how at annoying it was to have to copy and paste between my editor and the template manager. :D

cheesegrits 02-14-2008 11:56 PM

Quote:

Originally Posted by SirAdrian (Post 1442660)
Right now it defaults to the MASTER STYLE (-1) which is really what you should be using for any development, but I'm sure some of you are stubborn and will use it for customizing templates too. :)

Well, exactly! And why not? :)

I kinda thought that was the whole point of allowing us to export and import the vbulletin product. As unless we work for Jelsoft, we're unlikely to want to modify the master style for their templates. ;)

BTW, can you add one more teensy feature-ette, and allow us to define the file extension to use? I have added some extra smarts in Komodo to deal with template syntax as well as HTML, but the documents have to be of type .tpl. I stole the XUL from another Komodo extension that adds syntax support for Smarty templates, and tweaked it around a bit.

So, when do we get the APC (Automatic Phrase Compiler)?

-- hugh

Adrian Schneider 02-15-2008 12:31 AM

Always wanting more... lol

.html, sure. I'll upload the new copy I guess tomorrow, or maybe tonight.

Quote:

The PHP5 restriction is so lame!
Not as lame as having to use PHP 4!

MrNase 02-20-2008 06:53 AM

Quote:

Originally Posted by waza (Post 1442500)
hmm, if i edit a template (file) and save it and refresh my page it shows the changes.
But if I refresh my page again, they are gone...

Edit: i found the problem: he saved it in another style than the style i was working in.

How did you fix it? I have the same problems. :(

cheesegrits 02-20-2008 05:05 PM

In your ATC AdminCP settings, in "Configuration Data" you define what style ID the ATC should compile your templates into. For instance, mine looks like this:

./templates, vbulletin, 0, 1
./cheesegrits/staffid/templates, staffid,0,-1
./cheesegrits/aboutme/templates,aboutme,0,-1

The settings define the directory to use for the templates (which MUST be different for each product you create a config for), the product name, the product version (defaults to currently installed version if set to 0) and the styleID.

So I have two mods I'm actively working on (aboutme and staffid), so I'm using the master style for those. But for vB itself, I'm using the Default Style, so my vB template mods don't get written into the master style.

Oh, and you need to make sure you are running the latest version. The first couple of versions didn't have the styleID stuff.

-- hugh

MrNase 02-20-2008 06:03 PM

Thanks for helping me! :)

I have the latest version installed (at least I think so, I downloaded the file just a couple of hours ago) and I can't spot a setting where I could configure this Add-on.

I had a look the the product's xml file and it installs just one plugin:

PHP Code:

if ($vbulletin->debug)
{
    require_once(
DIR '/includes/class_auto_template_compiler.php');
    
$atc = new vB_Auto_Template_Compiler($vbulletin);

    if (
is_member_of($vbulletin->userinfo6) and $_GET['do'] == 'import')
    {
        
$atc->import_from_database(
            
DIR '/templates',
            
'vbulletin'
        
);
    }

    
$config = array(
        
'product' => 'your_product_id',
        
'version' => '1.0'
    
);

    
$atc->process_directory(DIR '/templates'$config); 


What do I have to change to make it work? :)

Adrian Schneider 02-20-2008 06:36 PM

The current release here has no options, so you just have to edit the plugin data ($config) to change the settings.

cheesegrits 02-20-2008 06:50 PM

Ooops! I could have sworn you'd released the new version I've been testing / using.

-- hugh

MrNase 02-21-2008 11:55 AM

Ok, I'll wait for the next version then. :)

cheesegrits 02-21-2008 03:03 PM

I'll bully AJ into getting it released ASAP! I'm still in shock at just how darn useful this mod is.

Oh, and I'll donate a "the" to your sig word collection. Copy, paste and use wisely.

-- hugh

ninjamaster 02-24-2008 08:03 AM

thanks nice work

Zachery 02-24-2008 10:20 AM

Nice, Don't really have a need for it as I've never found it a pain unless I was updating multiple styles to new versions or working en mass with lots of styles. Though I'm slightly suprised no one did this sooner seeing how part of this has been in the code for awhile.

Nice work :)

cheesegrits 02-24-2008 05:42 PM

I think you'd be amazed at how useful the ATC is, even if you don't do much template editing. You'll save the time it took you to install the ATC the first time you do need to edit a template. Template editing becomes just like PHP editing - make your changes to a simple HTML file using your IDE / code editor, and hit your page again.

I don't do a huge amount of template editing, but the ATC has already become one of those things I don't know how I lived without.

Even if you don't do template editing, just being able to dump all of vB's templates and include them in your IDE's "Search in Files" path is invaluable when trying to work out how vB does something. Like, what does $show['some_show_thingy'] do, how does it get set and where does it get used? One search in your IDE finds all occurrences in PHP and templates.

-- hugh

Guest210212002 02-24-2008 08:03 PM

Quote:

Originally Posted by Boofo (Post 1442076)
I sure wish you guys weren't PHP 4 haters. ;)

Me too. :(

[high]* Guest210212002 clicks install anyway
[/high]

I might actually upgrade to PHP5 just for this mod.

Adrian Schneider 02-24-2008 10:58 PM

Sorry for the huge delay in upgrades.

You can track the real progress of it at my dev. blog, and you may also be interested in the other upcoming or existing tools if you are serious about developing.

(ATC is being renamed to VDE -- vBulletin Development Environment and will soon work for the other product data aside from just templates).

SVN users will be pleased to see public SVN access.

cheesegrits 02-24-2008 11:57 PM

Quote:

Originally Posted by SirAdrian (Post 1450322)
SVN users will be pleased to see public SVN access.

And if you aren't an SVN user ... you should be. :)

A quick crash course for anyone unfamiliar with it, SVN is a "source control system". It allows developers to share and distribute the latest code. And because AJ's stuff is on a public SVN server with 'anonymous' access, anyone can use SVN to download AJ's latest and greatest, without having to wait till he gets round to updating the ZIP on this page.

For Windows, by far and away the best SVN client is Tortoise SVN:

http://tortoisesvn.net/downloads

Download and install it. Tortoise installs itself on your normal right click folder menu. Create a new folder somewhere called 'vbdevtools'. Right click in the new folder and select "SVN Checkout". In the "URL of Repository", paste this URL:

https://vbdevtools.svn.sourceforge.n...oot/vbdevtools

Click OK. Tortoise will now connect to the SVN server and download all the folders and files for AJ's 'vbdevtools' project. In ./vde/unstable you will find the ATC. To install / upgrade to it, do exactly what you would normally do - upload the uploads and install the XML.

From now on, whenever AJ updates his code, Tortoise will change the Green Tick folder icon on your 'vbdevtools' folder to a Red Exclamation Point icon. To download the updates, just right click the folder and select "SVN Update".

-- hugh

Antivirus 02-25-2008 02:01 AM

ah nice, I didnt know you released this publicly yet - i'll refer here from now on :)


All times are GMT. The time now is 07:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01356 seconds
  • Memory Usage 1,839KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete