Opened 10 years ago

Closed 10 years ago

# All pages imported by trac-admin are marked "system pages"

Reported by: Owned by: izzy Shun-ichi Goto normal TracWikiNegotiatorPlugin normal 0.10

### Description

To me it is not a rare case that I create wiki articles externally and the use trac-admin /path/to/env wiki import file page to insert it into the wiki. The result is, that all those pages will be listed as "system pages", which is quite confusing (though I guess I understand the reason). IMO it would be much better to decide based on something else, e.g. page names: All pages starting with "Trac" and "Wiki" are system pages, plus some other pages which can be named.

If you don't consider this a bug, maybe you can take it as RFE. I'd suggest some settings for the trac.ini file:

[wikinegotiator]
system_by_creator = true      # behaviour as it is now, so the next lines would be ignored
system_prefixes   = Trac,Wiki,Inter # pages starting with these strings are system pages
system_include    = CamelCase # additional pages to count as system pages
system_exclude    = Tracking  # false positives by prefix which are *not* system pages


This way one could adapt the behaviour to special needs :)

### comment:1 Changed 10 years ago by izzy

Until then, here's a kind of work-around for other people which may be affected by this issue. Use sqlite3 trac.db to edit the database, and fire the statement:

UPDATE wiki
SET author='Izzy'
WHERE author='trac'
AND name NOT LIKE 'Wiki%'
AND name NOT LIKE 'Trac%'
AND name NOT LIKE 'Inter%'
AND name NOT LIKE 'Camel%'
AND name NOT IN ('SandBox','RecentChanges','TitleIndex','PageTemplates');


Of course, you may want to replace the "author" by something else but my nick. And maybe you need to name some more exceptions.

In general, this statement would change all wiki articles currently marked as owned by "trac" to the author you specify - as long as the names do not indicate it is really a "system page". This trick makes sure you won't mess up the other users articles ownerships ;)

This statement would be needed to execute after each import via trac-admin then.

To make it even a bit easier, here's the whole thing as shell script:

#!/bin/bash
# own non-system pages by somebody else than "trac"

OWNER="Izzy" # whom to own the imported pages by default

[ -z "$1" ] && { echo "Syntax: " echo "$0 /path/to/trac/env [new_owner]"
exit 1
}

[ -n "$2" ] && OWNER="$2"

DB="$1/db/trac.db" [ ! -f$DB ] && {
echo "Could not find '$DB', exiting." exit 2 } sqlite3$DB <<EOF
UPDATE wiki
SET author="\$OWNER"
WHERE author='trac'
AND name NOT LIKE 'Wiki%'
AND name NOT LIKE 'Trac%'
AND name NOT LIKE 'Inter%'
AND name NOT LIKE 'Camel%'
AND name NOT IN ('SandBox','RecentChanges','TitleIndex','PageTemplates');
EOF


Save it somewhere, adapt to your needs, and call it with at least the trac environment path as parameter (optional 2nd parameter is the user the fresh imported files should be owned to). If no environment path is specified, or the trac.db file is not found, the script will put an error to the screen and exit. Otherwise it will update the database accordingly, and exit then.

### comment:2 Changed 10 years ago by Shun-ichi Goto

Resolution: → fixed new → closed

Thanks for your opinions. I've pushed a new implementation to pick up system pages (r4367). The new one get systemp page names by listing file names in wiki-default directory. And it does not care about author of the page. This will fix your issue.

As a side effect, some pages made by plugins (i.e. Graphviz* pages) goes to user page. So I added a new option explicit_system_pages (r4368). This option and existing explicit_user_pages are list of page names. The page name can be ends with '*' character for prefix match.

For example, you can set options like this:

[multi-lang-title-index]
explicit_user_pages = WikiStart, SandBox
explicit_system_pages =Graphviz*, Trac*


This example means WikiStart and SandBox pages are user page, and all the pages starting with "Graphviz" or "Trac" are system page.

Note: This feature works on both 0.10 and 0.11.

### Modify Ticket

Change Properties