[Zim-wiki] path link checking plugin

2016-02-08 Thread Nathaniel Beaver
I've written a plugin to check that the target of a file link exists 
(see prototype attached).


However, I'd like to turn the broken links a different color by 
accessing the gtk.TextTag corresponding to the link and changing the 
style with something like


tag.set_property('foreground', 'red')

Unfortunately, I am having some difficulty finding the actual TextTags 
in the parse tree. Right now I am using tree.findall(zim.formats.LINK) 
to get all the links, but the node.tag property is just a string, not a 
TextTag.


Any suggestions?

Nathaniel Beaver

P.S. Here is the GitHub page if it helps:

https://github.com/nbeaver/zim-pathchecker-plugin

and here is the relevant bug report:

https://bugs.launchpad.net/zim/+bug/1419531
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''Path check plugin based on zeitgeist-logger plugin.'''

import sys
import os.path
import urlparse

from zim.plugins import PluginClass, ObjectExtension, extends
from zim.signals import SIGNAL_AFTER
import zim.formats
import zim.parsing
import logging

import inspect

logger = logging.getLogger('zim.plugins.pathcheck')

class PathChecker(PluginClass):

	plugin_info = {
		'name': "Path Checker", # T: plugin name
		'description': "Checks for broken paths in links.", # T: plugin description
		'author': "Nathaniel Beaver",
	}

@extends('PageView')
class PageViewExtension(ObjectExtension):

	def __init__(self, plugin, pageview):
		self.plugin = plugin
		self.connectto(obj=pageview.ui, signal='open-page', handler=self.on_open_page, order=SIGNAL_AFTER)

	def yield_link_nodes(self, page):
		tree = page.get_parsetree()
		if tree:
			for node in tree.findall(zim.formats.LINK):
href = node.attrib.pop('href')
link_type = zim.parsing.link_type(href)
yield link_type, href, node

	def on_open_page(self, ui, page, path):
		logger.debug("Opened page: %s", page.name)
		for link_type, href, node in self.yield_link_nodes(page):

			if link_type == 'file':
if href.startswith('file://'):
	path = urlparse.urlparse(href).path
else:
	path = os.path.expanduser(href)
if not os.path.exists(path):
	logger.debug("Broken path: %s", path)
___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] Lets build a zim android app together!

2016-02-08 Thread Marco Cevoli
Thanks, Jaap, good to know. I've done mockups in the past, so I'll try
to find some time to design a first draft.

I don't know if I had the right to do it, but I created a specific
page on the Wiki:

https://github.com/jaap-karssenberg/zim-wiki/wiki/Android-app-design-and-development

The first step would be to collect the features that would go into the
Android app, so that I can create the mockup around them. That's why I
suppose that the app won't do _all_ the things that the Desktop app
does, but I might be wrong.

HIH

Marco Cevoli



On Mon, Feb 8, 2016 at 3:15 PM, Jaap Karssenberg
 wrote:
> Hi Marco,
>
> Afraid financing is not the limiting factor at this moment. Personally I
> have a full time job in engineering, so more income would not allow me to
> spent more time on zim.
>
> Besides, we actually have some money from donations, and so far it has
> proven more difficult to find people to take the money than to find people
> willing to donate ...
>
> At this time what we really need is a few volunteers with some coding / web
> skills that enjoy diving in and helping out.
>
> However I'm open to proposals to get some of this work done in exchange for
> money. After all, a lot of donations do mention an android app as their
> wishlist item.
>
> One task at this moment where non-techies could help is to make a mockup of
> how the application should look and describe where to click and what
> happens. This kind of thing you can draw out in any paint program. Putting
> it in the wiki allows for collaboration on this.
>
> Regards,
>
> Jaap
>
>
>
>
> On Mon, Feb 8, 2016 at 3:07 PM, Marco Cevoli  wrote:
>>
>> Have you considered crowdfund the effort? Creating a crowdfunding
>> project might give you the resources needed to jump-start the
>> development and would be an easy way for non-techies to express their
>> support.
>>
>> Just an idea.
>>
>> Best regards
>>
>> Marco Cevoli
>>
>> ___
>> Mailing list: https://launchpad.net/~zim-wiki
>> Post to : zim-wiki@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~zim-wiki
>> More help   : https://help.launchpad.net/ListHelp
>
>

___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] Lets build a zim android app together!

2016-02-08 Thread Marco Cevoli
Have you considered crowdfund the effort? Creating a crowdfunding
project might give you the resources needed to jump-start the
development and would be an easy way for non-techies to express their
support.

Just an idea.

Best regards

Marco Cevoli

___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] Lets build a zim android app together!

2016-02-08 Thread Brendan Kidwell
This looks like a good project plan. I hope other people join.

I don't have the energy to work on an effort like this, but I have one
suggestion of something to look into:

It looks like you'll be building a system that loads Zim wiki text into
an editable view built with HTML and JavaScript. You might want to check
out the CKGEdit plugin for DokuWiki. It's an adaptation of CKEditor
(HTML rich text editing widget) to work on DokuWiki page source code.

https://www.dokuwiki.org/plugin:ckgedit

I believe CKGEdit has a (mostly) 1-to-1 mapping of DokuWiki to
editable HTML and back. In practice I couldn't get it to work without
randomly inserting empty paragraphs after a table on my sandbox
DokuWiki page, but I'm sure the source code for CKGEdit is worth
looking into for ideas.

Brendan Kidwell


On Sun, Feb 7, 2016, at 15:13, Jaap Karssenberg wrote:
> The idea is to build on top of the python code base and use HTML for
> the interface. To make it a directed effort, I have started to draft a
> project plan with simple milestones here:
>
> https://github.com/jaap-karssenberg/zim-android-mockapp/wiki
___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp