Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Publicaciones sobre urssus

Yo sabía que no tenía que hacerlo, o como HTML5 y Qt hacen mi trabajo.

Des­de ha­ce un tiem­po quie­ro que ten­ga so­por­te de po­dcas­ts. El asun­to es que ... siem­pre me pa­re­ció mu­cho tra­ba­jo. Se­gu­ro, usan­do pho­non pue­do crear un re­pro­duc­tor de au­dio y eso, pe­ro­...

Es­toy usan­do un wi­dget HT­ML pa­ra mos­trar los pos­ts, así que ten­dría que en­con­trar una for­ma de agre­gar el re­pro­duc­tor a la in­ter­fa­ce y... mu­cho tra­ba­jo.

Hoy me des­per­té y pen­sé... es­pe­rá... El wi­dget HT­ML de Qt es­tá ba­sa­do en We­bki­t. Y we­bkit so­por­ta HT­M­L5. Y HT­M­L5 tie­ne un tag "au­dio­".

En­ton­ce­s, si hi­cie­ra que uR­S­Sus ba­ja­ra los li­nks de los en­clo­su­res, y los agre­ga­ra a la ba­se de da­to­s, y agre­go es­to al tem­pla­te de pos­t:

<?py for enclosure in  post.enclosures: ?>
  <audio autobuffer="Yes" controls="controls" src=#{enclosure.href}></audio><br>
<?py #end ?>

Eso no fun­cio­na­ría? Bue­no, sí!

urssus26

Y ahí es­tá, yo te­nia ra­zón en no im­ple­men­tar­lo, por­que la for­ma fá­cil de ha­cer­lo es de­jar que Qt lo ha­ga ;-)

Using assistant from PyQt

The uRSSus doc is slow­ly grow­ing, so I hooked as­sis­tant to the UI. Not dif­fi­cult, but I have not seen it else­where.

Here's how:

As­sume the "Hand­book ac­tion" is called ac­tion_Hand­book. Set win­dow.as­sis­tant to None in __init__.

def on_action_Handbook_triggered(self, i=None):
    if i==None: return

    if not self.assistant or \
       not self.assistant.poll()==None:

        helpcoll=os.path.join(os.path.abspath(os.path.dirname(__file__)),\
                              'help',\
                              'out',\
                              'collection.qhc')
        cmd="assistant -enableRemoteControl -collectionFile %s"%helpcoll
        self.assistant=subprocess.Popen(cmd,
                                        shell=True,
                                        stdin=subprocess.PIPE)
    self.assistant.stdin.write("SetSource qthelp://urssus/doc/handbook.html\n")

And that's it. Now I ned to fig­ure out con­text help.

Now you, too can create Qt Help Files painlessly

I de­cid­ed to add a man­u­al for uRSSus. Since it's a Qt ap­p, I checked how to do one of those neat help files, like the ones that come with Qt app­s.

It turns out it's not so sim­ple to cre­ate one of those.

You need to cre­ate your help in one or more HTML files, then cre­ate a XML file that de­scribes what each file is, ref­er­ences for each sec­tion, and ref­er­ences for each key­word you want in the in­dex.

For any re­al-life-­size doc­u­men­t, that's go­ing to be in­cred­i­bly an­noy­ing.

So, I took my usu­al es­cape route when I don't want to do grunt work on doc­s: Do­cu­tils.

Specif­i­cal­ly, I wrote rst2qhc which takes one (or more) re­struc­tured text files, and cre­ates a nice and clean Qt Help Project file from them, in­clud­ing sec­tion ti­tles, ref­er­ences and key­word­s, which you mark on the text us­ing the 'key­word' role.

What does this mean? Let me be graph­i­cal:

rst2qhc2

The one on the right is nice to read. The one on the left is nice to write. The ar­row in the mid­dle is rst2qhc :-)

And here's how the gen­er­at­ed qhp file looks for a triv­ial out­line of a man­u­al (and the rea­son why I don't want to do this man­u­al­ly ;-):

<?xml version="1.0" encoding="UTF-8"?>
<QtHelpProject version="1.0">
    <namespace>urssus</namespace>
    <virtualFolder>doc</virtualFolder>
    <customFilter name="Unknown">
        <filterAttribute></filterAttribute>
    </customFilter>
    <filterSection>
        <filterAttribute></filterAttribute>
        <toc>
            <section title="The uRSSus Handbook" ref="manual.html">
                <section title="Introduction" ref="manual.html#introduction"/>
                <section title="Quick Start" ref="manual.html#quick-start"/>
                <section title="Configuration" ref="manual.html#configuration"/>
                <section title="Credits and License" ref="manual.html#credits-and-license"/>
            </section>
        </toc>
        <keywords>
                <keyword name="what can you" ref="manual.html#what-can-you-do-using-urssus"/>
                <keyword name="quick" ref="manual.html#quick-start"/>
                <keyword name="main window" ref="manual.html#the-main-window"/>
        </keywords>
        <files>
                <file>manual.html</file>
        </files>
    </filterSection>
</QtHelpProject>

Al­so, as a bonus, you can cre­ate PDF, La­TeX, HTML and ODT files from the same source (heck, you can cre­ate freak­ing man pages).

uRSSus 0.2.12 released!

Yay!

An­nounc­ing re­lease 0.2.12 or uRSSus a RSS/Atom ag­gre­ga­tor.

This re­lease fix­es the big crashy up­dater bug in 0.2.11, and makes some mi­nor im­prove­ments, like nicer date dis­play, and a xdg re­source in­stall­er.


Contents © 2000-2023 Roberto Alsina