Mailing List Archive

remove a wiki?
Pardon me if this is in the documentation but I can't find it anywhere.

Is it possible to delete a wiki from the system?

thanks,
Kevin
Re: remove a wiki? [ In reply to ]
Kevin Lewandowski <kevinsl@...> writes:

>
> Pardon me if this is in the documentation but I can't find it anywhere.
>
> Is it possible to delete a wiki from the system?
>
> thanks,
> Kevin
>
I didn't find a way to delete wiki page using the web interface. But what I
ended up doing was to use sqlite and then delete it from the database.

$ sqlite trac.db
sqlit> DELETE FROM wiki WHERE name='NameOfPage';

Eric
Re: remove a wiki? [ In reply to ]
>I didn't find a way to delete wiki page using the web interface. But what I
>ended up doing was to use sqlite and then delete it from the database.
>
>$ sqlite trac.db
>sqlit> DELETE FROM wiki WHERE name='NameOfPage';
>
>

If you're interested in, I wrote a very small Python script to remove
Wiki pages which are orpheanous (ie not referenced by any other Wiki
page), and prevents from removing referenced ones.
Until this feature is available in the official release, it is a simple
but efficient work around.

Regards,
Emmanuel.
Re: remove a wiki? [ In reply to ]
Emmanuel Blot wrote:
>
> If you're interested in, I wrote a very small Python script to remove
> Wiki pages which are orpheanous (ie not referenced by any other Wiki
> page), and prevents from removing referenced ones.
> Until this feature is available in the official release, it is a simple
> but efficient work around.
>

I am interested in this script ;-)

Regards


--
--
********************************************************************
* *
* Bas van der Vlies e-mail: basv@sara.nl *
* SARA - Academic Computing Services phone: +31 20 592 8012 *
* Kruislaan 415 fax: +31 20 6683167 *
* 1098 SJ Amsterdam *
* *
********************************************************************
Re: remove a wiki? [ In reply to ]
> I am interested in this script ;-)

I'm not sure the email web interface works with attachments. Hope it is...
I also copy it as regular ASCII text. Please use the attached file if possible.

Here is the script.
It may break some Trac rule, and can be surely improved.
However, my understanding is that the 'delete' feature will be available in a
forthcoming release of Trac; I haven't spent much time on it, and my Python
skills are not that good.

It only checks Wiki pages for orpheanous pages. It does not check other kind of
text that may refer to those (not-that-)orpheanous pages (e.g. defect tracking
pages, ...). You've been warned.


import sys
import os
import sqlite

class Orphean:
def __init__ (self):
self.dbname = None
if len (sys.argv) > 2:
if sys.argv[1][0] == '-':
self.usage('first argument should not be an option')
sys.exit(-1)
self.dbname = sys.argv[1]

if sys.argv[2] in ['-h','--help']:
self.usage()
sys.exit(0)

if sys.argv[2] in ['-l', '--list']:
sys.exit(self.list())

if sys.argv[2] in ['-d', '--delete']:
if len (sys.argv) < 4:
self.usage('wikipage name not specified')
else:
sys.exit(self.delete(sys.argv[3]))
else:
self.usage('invalid command: %s' % sys.argv[2])
sys.exit(-1)
else:
self.usage()
sys.exit(-1)

def usage(self, msg = None):
print "%s <dbenv> [-d WikiPage] [-l] [-h]" % sys.argv[0]
print " <dbenv> Trac database path"
print " -l list orpheanous pages"
print " -d WikiPage delete WikiPage from the Wiki DB"
if msg != None:
print "Error: %s" % msg

def opendb(self):
if self.dbname == None:
self.usage('Trac DB not specified')
sys.exit(-1)
dbpath = "%s/%s" % (self.dbname, "db/trac.db")

if not os.access(dbpath, os.R_OK):
self.usage('Trac DB not found in %s' % self.dbname)
sys.exit(-1)

self.cnx = sqlite.connect(dbpath, timeout=10000)

def loadpages(self):
self.opendb()
cursor = self.cnx.cursor()
self.wikipages = {}

cursor.execute ('SELECT name, version FROM wiki ORDER BY name')
while 1:
row = cursor.fetchone()
if row == None:
break
self.wikipages.setdefault(row[0], [])

for wikipage in self.wikipages.keys():
cursor.execute('SELECT version, text FROM wiki WHERE name=%s ORDER
BY version DESC LIMIT 1', wikipage)
row = cursor.fetchone()
if row:
version = int(row[0])
text = row[1]
for currentpage in self.wikipages.keys():
if currentpage == wikipage:
continue
if text.count(currentpage) > 0 :
if wikipage not in self.wikipages[currentpage]:
self.wikipages[currentpage].append(wikipage)

def list(self):
self.loadpages()

orpheans = 0
for page in self.wikipages.keys():
if len(self.wikipages[page]) == 0:
orpheans += 1
print "Orpheanous page %s" % page

return orpheans

def delete(self, wikipage):
self.loadpages()

if (wikipage == None) or wikipage == '':
return -1

if not self.wikipages.has_key(wikipage):
print "Wikipage '%s' does not exist" % wikipage
return -1

references = len(self.wikipages[wikipage])
if references > 0:
print "Wikipage '%s' is referenced %d time(s) in the following
page(s)" % (wikipage, references)
for page in self.wikipages[wikipage]:
print " %s" % page
return -1

cursor = self.cnx.cursor()
cursor.execute ('DELETE FROM wiki WHERE name=%s', wikipage)
self.cnx.commit()
print "deleting Wikipage '%s'" % wikipage
return 0

orphean = Orphean()
Re: remove a wiki? [ In reply to ]
> I am interested in this script ;-)

I'm not sure the email web interface works with attachments. Hope it is...
I also copy it as regular ASCII text. Please use the attached file if possible.

Here is the script.
It may break some Trac rule, and can be surely improved.
However, my understanding is that the 'delete' feature will be available in a
forthcoming release of Trac; I haven't spent much time on it, and my Python
skills are not that good.

It only checks Wiki pages for orpheanous pages. It does not check other kind of
text that may refer to those (not-that-)orpheanous pages (e.g. defect tracking
pages, ...). You've been warned.


import sys
import os
import sqlite

class Orphean:
def __init__ (self):
self.dbname = None
if len (sys.argv) > 2:
if sys.argv[1][0] == '-':
self.usage('first argument should not be an option')
sys.exit(-1)
self.dbname = sys.argv[1]

if sys.argv[2] in ['-h','--help']:
self.usage()
sys.exit(0)

if sys.argv[2] in ['-l', '--list']:
sys.exit(self.list())

if sys.argv[2] in ['-d', '--delete']:
if len (sys.argv) < 4:
self.usage('wikipage name not specified')
else:
sys.exit(self.delete(sys.argv[3]))
else:
self.usage('invalid command: %s' % sys.argv[2])
sys.exit(-1)
else:
self.usage()
sys.exit(-1)

def usage(self, msg = None):
print "%s <dbenv> [-d WikiPage] [-l] [-h]" % sys.argv[0]
print " <dbenv> Trac database path"
print " -l list orpheanous pages"
print " -d WikiPage delete WikiPage from the Wiki DB"
if msg != None:
print "Error: %s" % msg

def opendb(self):
if self.dbname == None:
self.usage('Trac DB not specified')
sys.exit(-1)
dbpath = "%s/%s" % (self.dbname, "db/trac.db")

if not os.access(dbpath, os.R_OK):
self.usage('Trac DB not found in %s' % self.dbname)
sys.exit(-1)

self.cnx = sqlite.connect(dbpath, timeout=10000)

def loadpages(self):
self.opendb()
cursor = self.cnx.cursor()
self.wikipages = {}

cursor.execute ('SELECT name, version FROM wiki ORDER BY name')
while 1:
row = cursor.fetchone()
if row == None:
break
self.wikipages.setdefault(row[0], [])

for wikipage in self.wikipages.keys():
cursor.execute('SELECT version, text FROM wiki WHERE name=%s ORDER
BY version DESC LIMIT 1', wikipage)
row = cursor.fetchone()
if row:
version = int(row[0])
text = row[1]
for currentpage in self.wikipages.keys():
if currentpage == wikipage:
continue
if text.count(currentpage) > 0 :
if wikipage not in self.wikipages[currentpage]:
self.wikipages[currentpage].append(wikipage)

def list(self):
self.loadpages()

orpheans = 0
for page in self.wikipages.keys():
if len(self.wikipages[page]) == 0:
orpheans += 1
print "Orpheanous page %s" % page

return orpheans

def delete(self, wikipage):
self.loadpages()

if (wikipage == None) or wikipage == '':
return -1

if not self.wikipages.has_key(wikipage):
print "Wikipage '%s' does not exist" % wikipage
return -1

references = len(self.wikipages[wikipage])
if references > 0:
print "Wikipage '%s' is referenced %d time(s) in the following
page(s)" % (wikipage, references)
for page in self.wikipages[wikipage]:
print " %s" % page
return -1

cursor = self.cnx.cursor()
cursor.execute ('DELETE FROM wiki WHERE name=%s', wikipage)
self.cnx.commit()
print "deleting Wikipage '%s'" % wikipage
return 0

orphean = Orphean()
Re: Status of some internal trac feature [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I currently maintain a branch of trac inside my organisation,
currently it's a big diff, i want to know the feature that you want
inside the Trac,

i will try to create patch to trunk for feature that you want

following you can test feature inside one of my public project (gpl)

~ * User page : /user/username (email, name, team, role, assigned ticket)
~ (see http://dircproxy.securiweb.net/user/fharvey )

~ * New wiki link user:fharvey or [[user:fharvey Francois Harvey]]
~ (see http://dircproxy.securiweb.net/ link Francois Harvey at the end)

~ * Wiki security (support mod_authz for the wiki)
~ both read : Access to some/test/with/ACL is deny
~ and write : Write access is deny
~ (no setup inside this website)

~ * Wiki stats (log the number of read of a wiki page)
~ * a new macro [[PopularPage(limit)]] that show the most popular page
~ (see http://dircproxy.securiweb.net/PopularPage)

* Filename (with color) inside the Timeview for Changeset entry
~ (see http://dircproxy.securiweb.net/timeline)

~ * Attachement added to the ticket are listed inside the ChangeLog
~ (see http://dircproxy.securiweb.net/ticket/14)

Francois Harvey
SecuriWeb inc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)

iD8DBQFBI+a1bw9u6+cJxl4RAhHFAKCTM5oUb6NVhNRdes2EjJ0dxSHIUwCfYZBS
PyLE+cNToMTrmvH9ykHPo+E=
=cOhN
-----END PGP SIGNATURE-----
Re: Status of some internal trac feature [ In reply to ]
That are nice feautures ;-). I like the user, stat and attachment features.



Fran?ois Harvey wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I currently maintain a branch of trac inside my organisation,
> currently it's a big diff, i want to know the feature that you want
> inside the Trac,
>
> i will try to create patch to trunk for feature that you want
>
> following you can test feature inside one of my public project (gpl)
>
> ~ * User page : /user/username (email, name, team, role, assigned ticket)
> ~ (see http://dircproxy.securiweb.net/user/fharvey )
>
> ~ * New wiki link user:fharvey or [[user:fharvey Francois Harvey]]
> ~ (see http://dircproxy.securiweb.net/ link Francois Harvey at the end)
>
> ~ * Wiki security (support mod_authz for the wiki)
> ~ both read : Access to some/test/with/ACL is deny
> ~ and write : Write access is deny
> ~ (no setup inside this website)
>
> ~ * Wiki stats (log the number of read of a wiki page)
> ~ * a new macro [[PopularPage(limit)]] that show the most popular page
> ~ (see http://dircproxy.securiweb.net/PopularPage)
>
> * Filename (with color) inside the Timeview for Changeset entry
> ~ (see http://dircproxy.securiweb.net/timeline)
>
> ~ * Attachement added to the ticket are listed inside the ChangeLog
> ~ (see http://dircproxy.securiweb.net/ticket/14)
>
> Francois Harvey
> SecuriWeb inc.

--
--
********************************************************************
* *
* Bas van der Vlies e-mail: basv@sara.nl *
* SARA - Academic Computing Services phone: +31 20 592 8012 *
* Kruislaan 415 fax: +31 20 6683167 *
* 1098 SJ Amsterdam *
* *
********************************************************************
Re: Status of some internal trac feature [ In reply to ]
On Wed, 18 Aug 2004 19:31:02 -0400, Fran?ois Harvey
<fharvey@securiweb.net> wrote:
> i will try to create patch to trunk for feature that you want
>
> following you can test feature inside one of my public project (gpl)
>
> ~ * User page : /user/username (email, name, team, role, assigned ticket)
> ~ (see http://dircproxy.securiweb.net/user/fharvey )

Awesome. Eventually it might even be interesting to be able to see
"recent commits".

> ~ * New wiki link user:fharvey or [[user:fharvey Francois Harvey]]
> ~ (see http://dircproxy.securiweb.net/ link Francois Harvey at the end)

Also very useful.

> ~ * Wiki security (support mod_authz for the wiki)
> ~ both read : Access to some/test/with/ACL is deny
> ~ and write : Write access is deny
> ~ (no setup inside this website)
>
> ~ * Wiki stats (log the number of read of a wiki page)
> ~ * a new macro [[PopularPage(limit)]] that show the most popular page
> ~ (see http://dircproxy.securiweb.net/PopularPage)

Is there a way to show the "top N" pages? I think that'd be even more
useful if you've got the stats. But it might also be useful to know
where people aren't looking, because it's a good indicator of dead
pages or things that aren't prominantly linked.

> * Filename (with color) inside the Timeview for Changeset entry
> ~ (see http://dircproxy.securiweb.net/timeline)

Very nice.

> ~ * Attachement added to the ticket are listed inside the ChangeLog
> ~ (see http://dircproxy.securiweb.net/ticket/14)

Excellent. ;-)

All look great to me.

Chris
--
| Christopher Petrilli
| petrilli@gmail.com
Re: remove a wiki? [ In reply to ]
>> I didn't find a way to delete wiki page using the web interface. But
>> what I
>> ended up doing was to use sqlite and then delete it from the database.
>>
>> $ sqlite trac.db
>> sqlit> DELETE FROM wiki WHERE name='NameOfPage';
>>
>
> If you're interested in, I wrote a very small Python script to remove
> Wiki pages which are orpheanous (ie not referenced by any other Wiki
> page), and prevents from removing referenced ones.
> Until this feature is available in the official release, it is a simple
> but efficient work around.

Please find an update.
The script was not using a rational expression to find wiki page names in other wiki pages,
which causes troubles with some wiki names.


import sys
import os
import sqlite
import re

class Orphean:

_wikiRE =
re.compile(r"""(^|(?<=[^A-Za-z]))[!]?[A-Z][a-z0-9/.]+(?:[A-Z][a-z0-9/.]*[a-z0-9/])+(?=\Z|\s|,|\.|:)""")

def __init__ (self):
self.dbname = None
if len (sys.argv) > 2:
if sys.argv[1][0] == '-':
self.usage('first argument should not be an option')
sys.exit(-1)
self.dbname = sys.argv[1]

if sys.argv[2] in ['-h','--help']:
self.usage()
sys.exit(0)

if sys.argv[2] in ['-l', '--list']:
sys.exit(self.list())

if sys.argv[2] in ['-d', '--delete']:
if len (sys.argv) < 4:
self.usage('wikipage name not specified')
else:
sys.exit(self.delete(sys.argv[3]))
else:
self.usage('invalid command: %s' % sys.argv[2])
sys.exit(-1)
else:
self.usage()
sys.exit(-1)

def usage(self, msg = None):
print "%s <dbenv> [-d WikiPage] [-l] [-h]" % sys.argv[0]
print " <dbenv> Trac database path"
print " -l list orpheanous pages"
print " -d WikiPage delete WikiPage from the Wiki DB"
if msg != None:
print "Error: %s" % msg

def opendb(self):
if self.dbname == None:
self.usage('Trac DB not specified')
sys.exit(-1)
dbpath = "%s/%s" % (self.dbname, "db/trac.db")

if not os.access(dbpath, os.R_OK):
self.usage('Trac DB not found in %s' % self.dbname)
sys.exit(-1)

self.cnx = sqlite.connect(dbpath, timeout=10000)

def loadpages(self):
self.opendb()
cursor = self.cnx.cursor()
self.wikipages = {}

cursor.execute ('SELECT name, version FROM wiki ORDER BY name')
while 1:
row = cursor.fetchone()
if row == None:
break
self.wikipages.setdefault(row[0], [])

for wikipage in self.wikipages.keys():
cursor.execute('SELECT version, text FROM wiki WHERE name=%s ORDER BY version DESC
LIMIT 1', wikipage)
row = cursor.fetchone()
if row:
version = int(row[0])
text = row[1]
wikire = self._wikiRE
wikiiter = wikire.finditer(text)
for wikimatch in wikiiter:
wikilink = wikimatch.group(0)
# skips self references
if wikilink == wikipage:
continue
# skips escaped wiki link
if wikilink[0] == '!':
continue
if not self.wikipages.has_key(wikilink):
self.wikipages[wikilink] = []
if wikipage not in self.wikipages[wikilink]:
self.wikipages[wikilink].append(wikipage)

def list(self):
self.loadpages()

orpheans = 0
for page in self.wikipages.keys():
if len(self.wikipages[page]) == 0:
orpheans += 1
print "Orpheanous page %s" % page

return orpheans

def delete(self, wikipage):
self.loadpages()

if (wikipage == None) or wikipage == '':
return -1

if not self.wikipages.has_key(wikipage):
print "Wikipage '%s' does not exist" % wikipage
return -1

references = len(self.wikipages[wikipage])
if references > 0:
print "Wikipage '%s' is referenced %d time(s) in the following page(s)" % (wikipage,
references)
for page in self.wikipages[wikipage]:
print " %s" % page
return -1

cursor = self.cnx.cursor()
cursor.execute ('DELETE FROM wiki WHERE name=%s', wikipage)
self.cnx.commit()
print "deleting Wikipage '%s'" % wikipage
return 0

orphean = Orphean()