wordpresssc

I’ve just wrote my first WordPress public plugin, that I’m licensing under GPL v3. This post is to make it public. I’m writing in English because the WordPress plugin directory asks me to provide a plugin page to host the files there and I’ll provide the URL of this post. Update: The plugin is now in the WordPress plugin directory: wordpress.org/extend/plugins/retrospective/


The website of the brazilian newspaper O Estado de São Paulo has a nice way to display news in a retrospective-style (check this screenshot or this link — Flash required).

Wouldn’t it be nice if we could display WordPress posts in our pages and categories in the same way just by using a shortcode? The possibilities are many. That’s why I wrote the Retrospective plugin for WordPress.

It has at least two advantages over the version you just saw:

  1. Does not require Flash (its implementation uses only CSS and JavaScript/jQuery)
  2. Has a option to respect the (time-)scale of the posts.

Its use is very simple. Wherever you add the shortcode [retrospective] the plugin will draw that cool retrospective. The shortcode supports several attributes:

  • count — limit the number of posts to be displayed (default = 10; use -1 to display all)
  • cat — display posts with category IDs comma-separated (default = display all posts)
  • width — the width of the timeline in pixels (default = 600)
  • delay — the time of the focus change animation in milisseconds (default = 1000)
  • scale — if set, respect the time scale in the distances between the points in the timeline (default = false)
  • image_width, image_height — the dimensions of the thumbnail images in pixels (default = 300×180)
  • image_border_size — the size of the image’s border in pixels (default = 7)
  • image_border_color — the color of the image’s border in hexa RGB (default = 000000)
  • image_margin — the space between the images (default = 5)
  • date_format — the date format in PHP format (default = d/m/Y)

For example, here is a [retrospective count=5 cat=41 image_border_color=2F5971] call:

  • eris
  • a2
  • libre-planet
  • stallman
  • wordpresssc

Some screenshots

Here is a screenshot from juntos.org.br with scale=true (in the link you can see it working):

And here is a screenshot from a fresh WordPress install (TwentyEleven theme without modifications):


Customizing

Post thumbnails

For better results, I suggest always adding post thumbnails to your posts and using registered image sizes in image_width and image_height attributes.

Styling retrospectives

The generated HTML is very easy to style (but just be careful with margins and paddings, they’re set with !important attribute — I did it to try not to break with any theme). Here is a sample:

<div id="retro-uniquehash" class="retrospective">
    <!-- TIMELINE -->
    <ul class="time">
        <li rel="0"><a href="permalink" style="left:0px;"><span>date</span></a></li>
        <li rel="1"><a href="permalink" style="left:300px;"><span>date</span></a></li>
        <li rel="2"><a href="permalink" style="left:600px;"><span>date</span></a></li>
    </ul>
 
    <!-- PHOTOS -->
    <div class="photos">
        <ul>
            <li rel="0"><a href="permalink" title="title">
                <img src="file" class="wp-post-image" /></a></li>
            <li rel="1"><a href="permalink" title="title">
                <img src="file" class="wp-post-image" /></a></li>
            <li rel="2"><a href="permalink" title="title">
                <img src="file" class="wp-post-image" /></a></li>
        </ul>
    </div>
 
    <!-- POSTS -->
    <ul class="posts">
        <li rel="0"><a href="permalink" title="title"><h2>Title <span>(date)</span></h2>
            <p>Excerpt</p></a></li>
        <li rel="1"><a href="permalink" title="title"><h2>Title <span>(date)</span></h2>
            <p>Excerpt</p></a></li>
        <li rel="2"><a href="permalink" title="title"><h2>Title <span>(date)</span></h2>
            <p>Excerpt</p></a></li>
    </ul>
</div>

Styling a specific retrospective

The generated hash takes in consideration all the attributes sent to the shortcode and also how many retrospectives appeared before in the parsing of the actual page. I made it that way to allow users to set up two exactly equal retrospectives in the same page. Because of that, I don’t recommend setting styles for #retro-uniquehash. I think a reasonable solution for this issue is to make something like

<div id="something_that_makes_sense">[retrospective]</div>

when inserting the shortcode and then styling #something_that_makes_sense .retrospective.


Download

Here is the code for download:* retrospective.zip
* Warning: Please consider I’m using a bazaar approach here. Be aware that the plugin probably has a lot of bugs (and please tell me if you catch any).

I hope you enjoy it. Have fun and please let me have your feedback! :)

 
stallman

(por Richard Stallman)

Pessoas de fora do movimento do software livre frequentemente perguntam sobre as vantagens práticas do software livre. É uma pergunta curiosa.

Software não-livre é ruim porque ele nega sua liberdade. Logo, perguntar sobre as vantagens práticas do software livre é como perguntar sobre as vantagens práticas de não ser algemado. De fato, isso tem vantagens:

  • Você pode usar uma camiseta normal.
  • Você pode passar por detectores de metal sem ativá-los.
  • Você pode ficar com uma mão no volante enquanto troca as marchas.
  • Você pode arremessar uma bola de baseball.
  • Você pode carregar uma mochila.

Nós poderíamos encontrar mais, mas você precisa dessas vantagens para convencê-lo a rejeitar algemas? Provavelmente não, porque você entende que é a sua liberdade que está em jogo.

Uma vez que você percebe que é isso que está em jogo com software não-livre, você não precisa perguntar que vantagens práticas o software livre possui.

Original (em inglês): http://www.gnu.org/philosophy/practical.html

 
libre-planet

by Peter Brown, FSF Executive Director
(Free Software Foundation Bulletin, Issue 16, May 2010)

Camiseta LibrePlanet A few weeks ago, my six-year-old son Michael looked at my t-shirt from our LibrePlanet conference and started asking me to name each of the various characters and objects shown in the t-shirt design. These characters are the mascots of various well-known (ahem) free software projects. Shame-faced, my memory slipped on a few and I had to go look them up for him.

The symbolism of the t-shirt is reinforced by the tag line “Working Together for Free Software” and this is a theme that the Free Software Foundation is working to promote within the community — that we need to do a better job driving awareness and solidarity to the cause of software freedom.

Free software is strong because of its values and because there are many heads to the free software hydra. For every project that goes moribund another two (dozen it seems) projects rise to take its place. But all too often we see high-profile projects, that are often corporately controlled, acting in ways that hurt free software, often putting their narrow self-interest ahead of the wider adoption of free software platforms, or promoting ancillary proprietary software at the expense of other free software projects. The most common problem is the lack of effort to educate users to the values of the free software they distribute. Leaving a typical user valuing the software only because it can be acquired for little or no cost.

Our campaign for software freedom is not a campaign for freedom of choice. Free software isn’t just an alternative to proprietary software. Free software is a social movement, a movement to rid the world of software that would otherwise be used to divide us and keep us powerless. The software we use is not a matter of utility or convenience, it is a matter of securing our freedom now and ever more so in a future where we become increasingly dependent on the integrity of the software we run.

In the US, we may have a Bill of Rights that prevents government from restricting free speech, free press or free assembly, but government can be ignored and these rights removed when proprietary software corporations have control over a citizen’s computing.

We need to strengthen the free software movement for the long haul. The key to this is to impress software freedom values on our friends and all the people we introduce to free software. Our campaign asks free software supporters and projects to promote free software in ways that consistently emphasize everyone’s right to freedom.

Working Together for Free Software means:

  • Telling all users that they deserve to have freedom and that they should be in control of their computing.
  • Promoting free software as a civil liberty, that protects citizens from government and undue influence in their lives.
  • Prioritizing software development for free platforms, and to recognize that the aim is to eliminate proprietary software like any anti-social behavior.

Please join us in promoting our Working Together for Free Software campaign.

 
a2

Criei um ebuild para o Fluxbox com uma USE flag “ddate” baseado no fluxbox-1.1.1-r2 (que é o último ebuild no Portage neste exato momento). Usando ele, é possível ter o calendário santo-discordiano no Fluxbox do Gentoo.

Siga os passos abaixo para ter Fluxbox com suporte a ddate no seu Gentoo.

Baixando o ebuild e colocando ele num overlay

% wget http://blog.tiagomadeira.com/portage-fluxbox-1.1.1-0.tar.bz2
% su
% mkdir -p /usr/local/portage/x11-wm
% tar xjvf portage-fluxbox-1.1.1-0.tar.bz2 -C /usr/local/portage/x11-wm

Modificando o /etc/make.conf pra adicionar suporte ao overlay

Abra com seu editor preferido (e obviamente como root) o /etc/make.conf e adicione ao final dele:

PORTDIR_OVERLAY="/usr/local/portage"

Depois disso é necessário rodar um emerge --sync (ou eix-sync se você usa o eix :))

% emerge --sync

ACCEPT_KEYWORDS e USE flag

Marquei o pacote como instável. Para usar, se seu /etc/make.conf não tem ACCEPT_KEYWORDS=”~amd64″ (ou ~suaarquitetura se você não usa amd64), edite (criando, caso não exista) o arquivo /etc/portage/package.keywords adicionando:

=x11-wm/fluxbox-1.1.1-r10 ~amd64

(substitua ~amd64 por ~suaarquitetura)

Se você também não tem uma USE flag “ddate” no /etc/make.conf, é necessário editar o arquivo /etc/portage/package.use (também crie se não existir), adicionando:

x11-wm/fluxbox ddate

E agora?

Basta instalar o Fluxbox usando o emerge, como você faria com qualquer pacote normal:

% emerge -av fluxbox
These are the packages that would be merged, in order:
 
Calculating dependencies... done!
[ebuild   U   ] x11-wm/fluxbox-1.1.1-r10  USE="ddate imlib nls slit toolbar truetype vim-syntax -gnome -newmousefocus -xinerama" 0 kB [1]

(note que a versão é 1.1.1-r10 e tem a USE flag ddate)

Ele não baixa o pacote inteiro do ddate, mas apenas aplica, além dos patches do Gentoo, um pequeno patch (de umas 40 linhas) que altera o ClockTool.cc.

Screenshot do emerge

Divirta-se!

 
eris

Acabei de implementar o calendário santo-discordiano no Fluxbox 1.1.1 (última versão).

Link para download do código: fluxbox-ddate-1.1.1-0.tar.bz2

Se você usa Arch Linux, não precisa baixar e compilar manualmente. Basta usar o pkgbuild que o Rev. Beraldo fez para o AUR: aur.archlinux.org/packages.php?ID=40364.

Se você usa Gentoo, não precisa baixar e compilar manualmente. Basta colocar o ebuild que eu fiz num overlay: fluxbox-ddate no Gentoo.

Versões compiladas .deb, .rpm, .tgz etc. e ebuilds, pkgbuilds etc. são bem vindos! Me passem que eu coloco um link aqui!

Como baixar e descompactar

Como você faria com qualquer outro pacote .tar.bz2…

$ wget http://blog.tiagomadeira.com/fluxbox-ddate-1.1.1-0.tar.bz2
$ tar xjvf fluxbox-ddate-1.1.1-0.tar.bz2
$ cd fluxbox-ddate-1.1.1-0

Como compilar

Versão simples:

$ ./configure
$ make
$ make install

Versão complicada:

$ export CFLAGS=-O2 -march=native -msse4.1
$ export CXXFLAGS=$CFLAGS
$ ./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --enable-nls --disable-xinerama --enable-xft --disable-gnome --enable-imlib2 --enable-slit --enable-toolbar --sysconfdir=/etc/X11/fluxbox
$ make -j3
$ make install

Encontre seu meio termo (ou use a simples) e divirta-se!

Como iniciar um Fluxbox

Inicie o X e peça pra ele abrir a versão que você compilou do Fluxbox da seguinte maneira:

$ startx /usr/local/bin/fluxbox -- :1

(Lembre-se de mudar /usr/local para o --prefix que usou no ./configure)

Esta linha funciona dentro de uma sessão do X (abre outra), por causa do -- :1.

Como usar a data discordiana

Clique com a tecla direita no relógio do seu Fluxbox e Edit clock format. Se você usar um formato de data convencional, do falso calendário (como deve estar usando no momento), nada de especial acontecerá. O segredo está no |fnord|.

Quando você coloca um |fnord| no formato, o Fluxbox interpretará tudo que veio antes como formato de data discordiano.

(Para escolher o formato de data ideal, você pode digitar man ddate num terminal.)

Exemplos de uso:

  • Formato: %c → Saída: Sat 28 Aug 2010 11:50:26 PM BRT
  • Formato: %e of %B of %Y|fnord| → Saída: 21st of Bureaucracy of 3176
  • Formato: %d %b %Y|fnord|, %H:%M:%S → Saída: 21 Bcy 3176, 23:50:26
  • Formato: %.|fnord| → Saída: All Hail Discordia!

Dúvidas, sugestões?

Contate a glândula pineal.

Como funciona o código?

O Fluxbox usa a função strftime para formatar a data do relógio. Isso acontece na linha 274 do arquivo src/ClockTool.cc. Modifiquei este trecho do código adicionando cerca de 23 linhas que separam a string do formato de data no |fnord| e passam o que vem antes dele como parâmetro para uma chamada de sistema pro ddate (sim, de fato pra próxima versão é melhor copiar o código do ddate ou reimplementar pra não ter este overhead) e o que vem depois continua indo pro strftime.

Ficou assim:

char s[255], u[255];
strcpy(s, m_timeformat->c_str());
char *t = strstr(s, "|fnord|");
time_string_len = 0;
if (t != NULL) {
	*t = '\0';
	sprintf(u, "ddate +'%s'", s);
	FILE *ddate = popen(u, "r");
	if (fgets(time_string, 255, ddate)) {
		time_string_len = strlen(time_string);
		time_string[--time_string_len] = '\0';
		fclose(ddate);
	}
	t+= 7;
} else {
	t = s;
}
time_string_len+= strftime(&time_string[time_string_len], 255 - time_string_len, t, time_type);

Known bugs

  1. Colocar ‘ (aspas simples) no lado esquerdo do |fnord| faz com que a data discordiana não apareça.
  2. Requer util-linux-ng e faz uma chamada de sistema ao ddate uma vez por segundo.
  3. Não trabalha ainda com horas métricas.
  4. … me informe se achar mais algum!

Screenshots

Screenshot 0

Screenshot 1

Screenshot 2

© 2012 Blog do Tiago Suffusion theme by Sayontan Sinha