2010년 7월 31일 토요일

Valuable plug-ins and macros for trac (1)

Edit all trac.ini options via the WebAdminPlugin(which is default from trac 0.11)

> sudo easy_install http://trac-hacks.org/svn/iniadminplugin/0.11

When it's not appeared on web administration page, especially on Trac 0.12, try it.

> cd /your/trac/env
> cd plugins
> ln -s /usr/local/lib/python2.6/dist-packages/IniAdmin-0.2-py2.6.egg

Manage schedule with Gantt's chart and calendar.

> cd /some/free/space
> svn co http://recurser.com/svn/ganttcalendar/trunk/ ganttcalendar
> cd ganttcalendar
> python setup.py bdist_egg
> sudo easy_install dist/TracGanttCalendarPlugin-0.1-py2.4.egg

Then, restart apache.

> /etc/init.d/apache2 restart

Finally, edit trac.ini

> cd /to/your/trac/env
> cd conf
> vi trac.ini

and insert it to some where.

[ticket-custom]
complete = select
complete.label = % Complete
complete.options = 0|5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100
complete.order = 3
due_assign = text
due_assign.label = Start (YYYY/MM/DD)
due_assign.order = 1
due_close = text
due_close.label = End (YYYY/MM/DD)
due_close.order = 2

AbbrMacro returns an or element with a title attribute.

[[Abbr(key=XYZ,title=Xenon Yeti Zulu,)]]

To use dictionary file, insert following texts into trac.ini.

[abbr]
file = /path/to/your/abbreviations/file

Then create dictionary file like this.

[acronym]
PEP = Python Enhancement Proposal
PHP = Hypertext Preprocesor
RFC = Request For Comments
...

[abbr]
...


BackLinks is a macro that can show you which wiki pages refer to the current page or to a page of your choice.

First download source zip file from above link and unzip it.
Rename BackLinks.5.py to BackLinks.py. (5 may be different actual version number)
Then copy it to python "dist-packages" directory.
And link to the file from "/your/trac/project/plugins" directory.

ln -s /your/pythone/dir/dist-packages/BackLinks.py

Finally, restart web server.

> /etc/init.d/apache2 restart

Example macro :

[[BackLinks]]
[[BackLinks(pagename)]]


Easy citation of resources. Gives wiki-pages the equivalent to LaTeX's \cite{} and \makeindex commands.

Download zipped source, and unzip it.
make egg.

> python setup.py bdist_egg

Copy egg file to "dist-packages".

> cp CiteMacro-0.1-py2.6.egg /path/to/your/python/dist-packages

Link to egg file from /your/project/plugins

> ln -s /path/to/your/python/dist-packages/CiteMacro-0.1-py2.6.egg

Restart web server.

> /etc/init.d/apache2 restart

To cite a resource use form : Cite(label, [description, [keywords]])
For example

A classic paper on software projects is Fred Brooks' No Silver Bullet [[Cite(brooks1995,author=Fred P. Brooks\, Jr.,
title=The Mythical Man-Month: Essays on Software Engineering, edition=Anniversary Edition,institution=University of
North Carolina,year=1995,publisher=Addison-Wesley,isbn=ISBN 0-201-83595-9,pages=179-203,
url=http://en.wikipedia.org/wiki/The_Mythical_Man-Month)]]. I would also recommend reading Eric Sink's Career Calculus
[[Cite(sink2003,reftype=electronic,author=Eric Sink,title=Career Calculus,url=http://www.ericsink.com/
Career_Calculus.html,year=2003,month=Aug,day=19)]] and Paul Graham's Great Hackers [[Cite(graham2004,
reftype=electronic,author=Paul Graham,title=Great Hackers,url=http://www.paulgraham.com/gh.html,month=Jul,year=2004)]].

If you are more interested in patents, try Nikola Tesla's first "Free Energy" patent [[Cite(tesla1901,reftype=patent,
assignee=Nikola Tesla,address=New York\, NY,number=685957,title=Apparatus for the Utilization of Radiant
Energy,day=5,month=Nov,year=1901,dayfiled=21,monthfiled=Mar,yearfiled=1901,nationality=United States,
url=http://www.google.com/patents?id=YitoAAAAEBAJ)]].

You can cite the same reference more then once:

Some stuff [[Cite(cite,Citation plugin,url=http://trac-hacks.org/wiki/CiteMacro)]] and then again [[Cite(cite)]] using only
the label.

Finally, at the bottom of the page generate the references:

[[Cite(references)]]

With back links, and a smaller heading.

[[Cite(references,h=2,backref=true)]]

The list of keywords was obtained from IEEEexample.bib,

author, assignee, nationality, editor, title, intype, booktitle, edition, series, journal, volume, number, organization,
institution, publisher, school, language, address, url, howpublished, dayfiled, monthfiled, yearfiled, day, month, year,
chapter, volume, paper, type, revision, pages, note, key

To create a BibTeX bibliography with a 4 space indentation.

[[Cite(bibtex,indent=4,style=background: #eee; border: 1px solid black; padding: 10px;)]]

Simply copy & paste the rendered output into your bibliography file.


The CodeExampleMacro renders a code example box that supports syntax highlighting. It support three types of examples: simple, correct, and incorrect. The SELECT ALL link highlights all of the code in the box to simplify the copy and paste action.

Download zipped source, and unzip it.
make egg.

> python setup.py bdist_egg

Copy egg file to "dist-packages".

> cp CodeExample-0.4.2-py2.6.egg /path/to/your/python/dist-packages

Link to egg file from /your/project/plugins

> ln -s /path/to/your/python/dist-packages/CodeExample-0.4.2-py2.6.egg

Restart web server.

> /etc/init.d/apache2 restart

The simple example:

{{{
#!CodeExample
#!python
def apply_timer(self):
timer = QTimer(self)
self.connect(timer, SIGNAL('timeout()'), self.update_statusbar)
timer.start(settings.HINTS_UPDATE_PERIOD)
}}}

The incorrect example:

{{{
#!BadCodeExample
#!python
def create_hint_list(self):
self.hints.extend(self.globals.get_hint_list())
}}}

The correct example:

{{{
#!GoodCodeExample
#!python
def update_statusbar(self):
self.combo_box.insertItem(0, self.hints.get_current_hint())
self.combo_box.setCurrentIndex(0)
}}}


A simple macro the create a colored sidebar.

{{{
#!NewsFlash
= Version 2.0 =
Version 2.0 has been released. Check out the [wiki:Download] page.

= New website =
Our project has a new website. Welcome!
}}}

Tyr this.

> easy_install http://trac-hacks.org/svn/newsflashmacro/0.11/

then restart web server.

> /etc/init.d/apache2 restart


NoteBox Plugin will render a HTML-DivContainer in different colors with different Icons.
The following containers are possible:

* [[NoteBox(warn, my Text)]]
o will render a red div-container with the given Text and a stopsign-image
* [[NoteBox(tip, my Text)]]
o will render a green div-container with the given Text and a lightbulb-image
* [[NoteBox(note, my Text)]]
o will render a blue div-container with the given Text and a notepaper-image

Try this.

> easy_install http://trac-hacks.org/svn/sectioneditplugin/0.11

then restart web server.

> /etc/init.d/apache2 restart

2010년 7월 23일 금요일

Some useful Ubuntu (or Linux) command

  • Check PCI devices

> lspci
> lspci | grep VGA

  • Check Video device

> lshw -C video

Change nvidia(GeForce4 MX 440 AGP) resolution on Ubuntu 10.04 LTS Lucid Lynx

Don't use restricted nvidia driver.
Just use nouveau driver.
Give up 3D acceleration. :<


See also Fixing the Monitor Resolution with xrandr - Ubuntu 10.04 LTS Lucid Lynx

> cvt 1280 1024
> xrandr --newmode "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
> xrandr --addmode VGA1 1280x1024_60.00
> xrandr --output VGA1 --mode 1280x1024_60.00

To make them permanent,

> vi /etc/gdm/Init/Default

then edit and save.

PATH=”/usr/bin:$PATH”
OLD_IFS=$IFS

xrandr --newmode "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
xrandr --addmode VGA1 1280x1024_60.00
xrandr --output VGA1 --mode 1280x1024_60.00

2010년 7월 22일 목요일

Fixing the Monitor Resolution with xrandr - Ubuntu 10.04 LTS Lucid Lynx

To read original document, follow the title link.

It's not tested yet.

Run terminal, then

> xrandr

You will get an output of the display(s) connected to your computer and the supported resolutions.


To get the settings for the 1280×1024 resolution, type the following at the terminal window

 > cvt 1280 1024

You’ll get the following output.


Then type

> xrandr --newmode

And paste to complete the command.

> xrandr -newmode "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync

Then type

> xrandr --addmode VGA1 1280x1024_60.00

VGA1 is your monitor name.


The LCD monitor should now be set to the correct resolution.
Unfortunately, the monitor settings only apply to the current session. If you reboot, the setting will be lost. To make them permanent, type

> gksudo gedit /etc/gdm/Init/Default
Look for
PATH=”/usr/bin:$PATH”
OLD_IFS=$IFS

and type the following and save.

xrandr –newmode “1280x1024_60.00″ 109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
xrandr –addmode VGA1 1280x1024_60.00
xrandr –output VGA1 –mode 1280x1024_60.00

It worked for me I hope it works for you. The original information was from a post on ubuntuforums.org.

2010년 7월 17일 토요일

How to - Managing trac project (Ubuntu platform)

1. Create project

Important!!!
- Don't use dash(-) in project name
- Don't create project and repository together in a directory

> sudo -i
> svnadmin create /home/svn/NewProject_reposit
> chown -R www-data.www-data /home/svn/NewProject_reposit
> trac-admin /home/trac/NewProject initenv
> chown -R www-data.www-data /home/trac/NewProject*

2. Add "TRAC_ADMIN"

> trac-admin /home/trac/NewProject permission add TRAC_ADMIN admin

Install Trac 0.11.7-1 on Ubuntu 10.04 LTS Lucid Lynx

Specifications.
- Multiple project support with Apache 2 web server
- mod_python module


Referenced documents

Another Ubuntu Hardy Heron mod_python HOWTO

Trac-0.11, Ubuntu 8.04, mod_python



1. Install trac from "Applications > Ubuntu software center"


2. Create trac folder

> sudo -i
> mkdir /home/trac
> chown www-data.www-data /home/trac

3. Setup password

> htpasswd -c /home/trac/password.txt admin
> chown www-data.www-data /home/trac/password.txt

4. Configure apache2

> vi /etc/apache2/sites-available/trac

Then, edit like below

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName trac.example.com
        DocumentRoot /home/trac
        ErrorLog /var/log/apache2/error.trac.log
        CustomLog /var/log/apache2/access.trac.log combined

        <Location /projects>
                SetHandler mod_python
                PythonInterpreter main_interpreter
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /home/trac
                PythonOption TracUriRoot /projects
                PythonOption PYTHON_EGG_CACHE /tmp
        </Location>

        # use the following for one authorization for all projects 
        # (names containing "-" are not detected):
        <LocationMatch "/projects/[[:alnum:]]+/login">
            AuthType Basic
            AuthName "trac"
            AuthUserFile /home/trac/password.txt
            Require valid-user
        </LocationMatch>
</VirtualHost>
 
5. Install "libapache2-mod-python" package with "System > Management > Synaptic Package Manager"
6. Install "libapache2-svn" package with "System > Management > Synaptic Package Manager"
Then reload apache2

> a2dissite default
> a2ensite trac
> /etc/init.d/apache2 reload
 
7. Create your project
 
> svnadmin create /home/trac/junkyard_reposit
> trac-admin /home/trac/junkyard initenv
Creating a new Trac environment at /home/trac/junkyard

Trac will first ask a few questions about your environment 
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> Junk Yard
 
 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]> 
 
 Please specify the type of version control system,
 By default, it will be svn.

 If you don't want to use Trac with version control integration,
 choose the default here and don't specify a repository directory.
 in the next question.

Repository type [svn]>                            

 Please specify the absolute path to the version control
 repository, or leave it blank to use Trac without a repository.
 You can also set the repository location later.

Path to repository [/path/to/repos]> /home/trac/junkyard_reposit
 
----------------------------------------------------------------------------------------------------------------------
Change folder owner
> chown -R www-data.www-data /home/trac/*
8. Setup subversion
Edit "/etc/apache2/mods-available/dav_svn.conf"
<Location /svn>
    # Uncomment this to enable the repository,
    DAV svn

    # Set this to the path to your repository
    SVNParentPath /var/lib/svn
 </Location>