<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>-= n8v =- &#187; plugin</title>
	<atom:link href="http://n8v.enteuxis.org/tags/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://n8v.enteuxis.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 27 Sep 2011 00:52:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-beta2-18055</generator>
		<item>
		<title>New WordPress Plugin to configure user timeouts</title>
		<link>http://n8v.enteuxis.org/2010/12/new-wordpress-plugin-to-configure-user-timeouts/</link>
		<comments>http://n8v.enteuxis.org/2010/12/new-wordpress-plugin-to-configure-user-timeouts/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 22:42:17 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Giving back]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=398</guid>
		<description><![CDATA[I published my second plugin for WordPress today. It lets you configure how long user sessions and the &#8220;remember me&#8221; cookie last. By default they&#8217;re only 2 days and 2 weeks, respectively. Twofold impetus: a problem with the internal P2 microblog at work when people like me left their browsers open for long periods, and the [...]]]></description>
			<content:encoded><![CDATA[<p>I published <a href="http://wordpress.org/extend/plugins/configure-login-timeout/">my second plugin for WordPress</a> today.  It lets you configure how long user sessions and the &#8220;remember me&#8221; cookie last. By default they&#8217;re only 2 days and 2 weeks, respectively.</p>

<p><a href="http://wordpress.org/extend/plugins/configure-login-timeout"><img class="aligncenter" title="Plugin screenshot" src="http://s.wordpress.org/extend/plugins/configure-login-timeout/screenshot-1.png?r=314559" alt="" width="387" /></a></p>

<p>Twofold impetus: a problem with the internal <a href="http://p2theme.com/">P2 microblog</a> at work when people like me left their browsers open for long periods, and the fact that I access too many WordPress blogs from too many different computers for the 2 week &#8220;Remember Me&#8221; timeout to be convenient enough.  Cranking it up to 22 years!</p>

<p>The <a href="http://wordpress.org/extend/plugins/configure-login-timeout/">WordPress documentation</a> is pretty great BTW.</p>

<p>And it was a little bit interesting to run in to the <a href="http://en.wikipedia.org/wiki/Year_2038_problem">Year 2038 problem</a> with 32-bit int timestamps.  I don&#8217;t know, it was fun working around the  &#8221;infinity&#8221; ceiling:</p>


<div class="wp_syntax"><div class="code"><pre class="php">  <span class="kw1">if</span> <span class="br0">&#40;</span> PHP_INT_MAX <span class="sy0">-</span> <a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&lt;</span> <span class="re0">$expire_in</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="re0">$expire_in</span> <span class="sy0">=</span>  PHP_INT_MAX <span class="sy0">-</span> <a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">-</span> <span class="nu0">5</span><span class="sy0">;</span>
  <span class="br0">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2010/12/new-wordpress-plugin-to-configure-user-timeouts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making a symfony plug-in for visual theme and custom errors</title>
		<link>http://n8v.enteuxis.org/2009/06/making-a-symfony-plug-in-for-visual-theme-and-custom-errors/</link>
		<comments>http://n8v.enteuxis.org/2009/06/making-a-symfony-plug-in-for-visual-theme-and-custom-errors/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 00:13:38 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=255</guid>
		<description><![CDATA[I manage a growing number of symfony-based Intranet apps that share a common look-and-feel. I use the same stylesheet and images on them all, and it I am nervous every time I make Yet Another Copy of the same files, knowing that I&#8217;m duplicating them and causing trouble for myself. Also, as I wrote in [...]]]></description>
			<content:encoded><![CDATA[<p>I manage a growing number of symfony-based Intranet apps that share a common look-and-feel.  I use the same stylesheet and images on them all, and it I am nervous every time I make Yet Another Copy of the same files, knowing that I&#8217;m duplicating them and causing trouble for myself.</p>

<p>Also, as I wrote in <a href="/2009/03/completely-custom-symfony-error-pages/">my post about custom error pages</a>, I have error pages set up for each, and I hate copying them.  So I have invested some time into building a plugin containing the visual assets and the customized error pages, so that it&#8217;s easier to keep them uniform across all the apps I work on, and so that it will be that much quicker to build new projects.</p>

<p>I don&#8217;t think anyone outside my company will want my plug-in, but these instructions will hopefully be useful for anyone who wants to do the same thing.</p>

<p><span id="more-255"></span></p>

<p>These instructions are for symfony 1.1 but they should apply equally to 1.0 and 1.2.</p>

<h2>Plugin organization</h2>

<p>Here are the files and directories in my plugin:</p>

<p><pre>plugins/myThemePlugin/
  config/
    view.yml
  modules/
    default/
      config/
        view.yml
      templates/
        disabledSuccess.php
        error404Success.php
  README
  web/
    css/
      mystyles.css
      myerrors.css
      mymain.css
    errors/
      error500.php
      unavailable.php
    images/
      my_swoop.jpg
      bg_sfTAlert.jpg
      bg_sfTLock.jpg
      bg_sfTMessage.jpg
      indicator.gif
      tall_gradient.jpg
</pre></p>

<h2>Using <code>svn:externals</code> to install the plugin in each symfony project</h2>

<p>I only want one copy of this thing, with version control, so I use svn:externals (for my other plugins too ).</p>

<p><pre>$ svn propget svn:externals plugins
myThemePlugin/        https://mysvnserver.com/svn/web/myThemePlugin
sfGuardPlugin/        http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1/
$ svn up
</pre></p>

<h2>Publishing the assets</h2>

<p>The <a href="http://www.symfony-project.org/book/1_2/17-Extending-Symfony#chapter_17_sub_anatomy_of_a_plug_in">chapter on plugins</a> in the <cite>The Definitive Guide to symfony</cite> explains:</p>

<blockquote>
  <p>Web assets (images, scripts, style sheets, etc.) are made available to the server. When you install a plug-in via the command line, symfony creates a symlink to the project <code>web/</code> directory if the system allows it, or copies the content of the module <code>web/</code> directory into the project one. If the plug-in is installed from an archive or a version control repository, you have to copy the plug-in <code>web/</code> directory by hand (as the <code>README</code> bundled with the plug-in should mention).</p>
</blockquote>

<p>As I showed above, I prefer to use <code>svn:externals</code> for my plugins, so this is a bit of a problem for me.  Also, I develop on Windows (with XAMPP and Cygwin), so the more elegant symlink solution is not an option.   Symfony 1.2 has a task called <code>plugin:publish_assets</code> that makes the copies, but that messes up my version control strategy. SO:  I am going to use <code>svn:externals</code> to get the web assets from my plugin too.</p>


<div class="wp_syntax"><div class="code"><pre class="bash">$ <span class="kw2">svn</span> propset <span class="kw2">svn</span>:externals <span class="st0">&quot;myThemePlugin  https://my_svn_server/svn/web/myThemePlugin/web/&quot;</span> web
$ <span class="kw2">svn</span> propget <span class="kw2">svn</span>:externals web
    myThemePlugin  https:<span class="sy0">//</span>my_svn_server<span class="sy0">/</span>svn<span class="sy0">/</span>web<span class="sy0">/</span>myThemePlugin<span class="sy0">/</span>web<span class="sy0">/</span>
$ <span class="kw2">svn</span> up</pre></div></div>


<p>This lets me keep the plugin in its own repository.  You could get a similar effect by just checking out the files, but it would clutter up the SVN for your main project.</p>

<p>The end result:  I have one copy of the web assets in the SVN repository, but they&#8217;re checked out twice into each project (once under <var>plugins/myThemePlugin/web</var> and once under <var>web/myThemePlugin</var>).</p>

<h2><var>view.yml</var> files</h2>

<p>Now the overall <var>view.yml</var> file in <var>plugins/myThemePlugin/config/</var> sets stylesheets for my whole project:</p>


<div class="wp_syntax"><div class="code"><pre class="yaml">default:
  stylesheets:    
    - /myThemePlugin/css/main: { position: last }
    - /myThemePlugin/css/bannerhealth: {position: last}
    - %SF_ADMIN_WEB_DIR%/css/main
    - %SF_CALENDAR_WEB_DIR%/skins/aqua/theme</pre></div></div>


<p>And I have another one to apply some additional stylesheets to my error pages:</p>


<div class="wp_syntax"><div class="code"><pre class="yaml">error404Success:
  metas:
    title:        404 Not Found
  stylesheets: 
    - /sf/sf_default/css/screen.css
    - /sf/sf_default/css/ie.css
    - /myThemePlugin/css/errors: {position: last}
&nbsp;
disabledSuccess:
  metas:
    title:        Temporarily Unavailable
  stylesheets: 
    - /sf/sf_default/css/screen.css
    - /sf/sf_default/css/ie.css
    - /myThemePlugin/css/errors: {position: last}</pre></div></div>


<h3>relative image paths in stylesheets and error pages</h3>

<p>I use relative paths in my stylesheets (served out of <var>myprojecturl/myThemePlugin/css/</var>) so they can find the images (<var>myprojecturl/myThemePlugin/images/</var>):</p>


<div class="wp_syntax"><div class="code"><pre class="css"><span class="kw1">background-image</span><span class="sy0">:</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="co2">../images/tall_gradient.jpg</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>


<p>I&#8217;d do the same if my error templates (like <var>plugins/myThemePlugin/modules/default/templates/error404Success.php</var>) used images, but they don&#8217;t.</p>

<p>The pages in <var>plugins/myThemePlugin/web/errors</var> (which are installed via <code>svn:externals</code> now in <var>web/myThemePlugin/errors</var>) are used when things are so broken symfony can&#8217;t build template pages, so they have full HTML structure, including full stylesheet tags:</p>


<div class="wp_syntax"><div class="code"><pre class="php"><span class="kw2">&lt;?php</span> <span class="re0">$path</span> <span class="sy0">=</span> <span class="st_h">'..'</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
&nbsp;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$path</span> <span class="sy1">?&gt;</span>/../sf/sf_default/css/screen.css&quot; /&gt;
&lt;!--[if lt IE 7.]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$path</span> <span class="sy1">?&gt;</span>/../sf/sf_default/css/ie.css&quot; /&gt;
&lt;![endif]--&gt;
&nbsp;
&nbsp;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$path</span> <span class="sy1">?&gt;</span>/css/main.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$path</span> <span class="sy1">?&gt;</span>/css/bannerhealth.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> <span class="re0">$path</span> <span class="sy1">?&gt;</span>/css/errors.css&quot; /&gt;</pre></div></div>


<h2>Apache error page configuration</h2>

<p>Finally, I tell Apache to use my customized error pages for errors in this project.</p>


<div class="wp_syntax"><div class="code"><pre class="apache">  &lt;<span class="kw3">Directory</span> <span class="st0">&quot;/path/to/myproject/web&quot;</span>&gt;
        <span class="kw1">ErrorDocument</span> <span class="nu0">404</span> /myproject/default/error404
	<span class="kw1">ErrorDocument</span> <span class="nu0">500</span> /myproject/bhThemePlugin/errors/error500.php
  &lt;/<span class="kw3">Directory</span>&gt;</pre></div></div>


<p>There we go!   Now I have a lot less to do each time I make a new app; all the pretty stuff is in my plugin, and there aren&#8217;t any surprisingly brown symfony pages to throw off any users.</p>

<p>What do you think?  Any errors or ommissions or problems?</p>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2009/06/making-a-symfony-plug-in-for-visual-theme-and-custom-errors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

