ADDED: NOTEDB::binary. so now 0.8 is ready for shipping !

FIXED:          regexp bug fixed. It was only possible to delete 2 items together
                separated by comma ("d 1,2,3,4" deleted only 1,2!).
ADDED:          Some new config options which reflects the new module structure.
                So you can change your database backend without the need to
                replace the note script itself.
FIXED:          the previously added feature "cd <topic>" didn't really work :-(
ADDED:          NOTEDB::mysql added. Perlmodule, which I will use within
                note from now on instead of buildin functions for accessing the
                database. From now on I only need to maintain one version of
                note, since the module interface will be identical between the
                bin and sql version.
CHANGED:        The SQL code does not use Mysql.pm anymore. Instead it is coded
                using the more portable DBI module. This allows one easily to
                switch to anther database, which is supported by DBI.
CHANGED:        Locking. The db-table will now be locked before note accesses it.
FIXED:          width of listings is now always the same independent of the string-
                length of a certain note.
This commit is contained in:
TLINDEN
2012-02-10 20:12:25 +01:00
parent 1ab897790c
commit f54d187c47
14 changed files with 2086 additions and 96 deletions

View File

@@ -1,5 +1,28 @@
==================================================================================
0.8:
ADDED: NOTEDB::binary. so now 0.8 is ready for shipping !
FIXED: regexp bug fixed. It was only possible to delete 2 items together
separated by comma ("d 1,2,3,4" deleted only 1,2!).
ADDED: Some new config options which reflects the new module structure.
So you can change your database backend without the need to
replace the note script itself.
FIXED: the previously added feature "cd <topic>" didn't really work :-(
ADDED: NOTEDB::mysql added. Perlmodule, which I will use within
note from now on instead of buildin functions for accessing the
database. From now on I only need to maintain one version of
note, since the module interface will be identical between the
bin and sql version.
CHANGED: The SQL code does not use Mysql.pm anymore. Instead it is coded
using the more portable DBI module. This allows one easily to
switch to anther database, which is supported by DBI.
CHANGED: Locking. The db-table will now be locked before note accesses it.
FIXED: width of listings is now always the same independent of the string-
length of a certain note.
==================================================================================
0.7:
ADDED: one can now use the unix-like "cd" command to change to another
topic, thus use "cd topicname" instead just typing "topicname"!

7
NOTEDB/README Normal file
View File

@@ -0,0 +1,7 @@
perl modules for note used as database backends.
the install.sh script will install both of them,
although you may only need one backend. Perhaps
other users on your system have oter ideas in mind...
Therefore, please ignore these file. There is nothing
to edit or to do. Simply leave this directory :-)

331
NOTEDB/binary.pm Normal file
View File

@@ -0,0 +1,331 @@
#!/usr/bin/perl
use strict;
use Data::Dumper;
use IO::Seekable;
package NOTEDB;
use Fcntl qw(LOCK_EX LOCK_UN);
# Globals:
my ($NOTEDB, $sizeof, $typedef,$version);
$version = "(NOTEDB::binary, 1.1)";
sub new
{
my($this, $dbdriver, $dbname, $MAX_NOTE, $MAX_TIME) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
$NOTEDB = $dbname;
if(! -e $NOTEDB)
{
open(TT,">$NOTEDB") or die "Could not create $NOTEDB: $!\n";
close (TT);
}
elsif(! -w $NOTEDB)
{
print "$NOTEDB is not writable!\n";
exit(1);
}
my $TYPEDEF = "i a$MAX_NOTE a$MAX_TIME";
my $SIZEOF = length pack($TYPEDEF, () );
$sizeof = $SIZEOF;
$typedef = $TYPEDEF;
return $self;
}
sub DESTROY
{
# clean the desk!
}
sub version {
return $version;
}
sub get_single
{
my($this, $num) = @_;
my($address, $note, $date, $buffer, $n, $t, $buffer, );
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
$address = ($num-1) * $sizeof;
seek(NOTE, $address, IO::Seekable::SEEK_SET);
read(NOTE, $buffer, $sizeof);
($num, $n, $t) = unpack($typedef, $buffer);
$note = ude($n);
$date = ude($t);
flock NOTE, LOCK_UN;
close NOTE;
return $note, $date;
}
sub get_all
{
my($this, $num, $note, $date, %res);
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
my($buffer, $t, $n);
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $sizeof)) {
($num, $note, $date) = unpack($typedef, $buffer);
$t = ude($date);
$n = ude($note);
$res{$num}->{'note'} = $n;
$res{$num}->{'date'} = $t;
}
flock NOTE, LOCK_UN;
close NOTE;
return %res;
}
sub get_nextnum
{
my($this, $num, $te, $me, $buffer);
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $sizeof)) {
($num, $te, $me) = unpack($typedef, $buffer);
}
$num++;
flock NOTE, LOCK_UN;
close NOTE;
return $num;
}
sub get_search
{
my($this, $searchstring) = @_;
my($buffer, $num, $note, $date, %res, $t, $n);
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $sizeof))
{
($num, $note, $date) = unpack($typedef, $buffer);
$n = ude($note);
$t = ude($date);
if($n =~ /$searchstring/i)
{
$res{$num}->{'note'} = $n;
$res{$num}->{'date'} = $t;
}
}
flock NOTE, LOCK_UN;
close NOTE;
return %res;
}
sub set_recountnums
{
my $this = shift;
my(@count, $i, $num, $setnum, $buffer, $buff, $note, $date);
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
$setnum = 1;
my $TEMP = "/tmp/note.$$"; # save temporarily in $TEMP
system("/bin/touch", $TEMP);
open TEMP, "+<$TEMP" or die "Could not open $TEMP($!)\n";
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $sizeof)) {
($num, $note, $date) = unpack($typedef, $buffer);
$buff = pack($typedef, $setnum, $note, $date);
seek(TEMP, 0, IO::Seekable::SEEK_END); # APPEND
print TEMP $buffer;
$setnum++;
}
close(TEMP);
flock NOTE, LOCK_UN;
close NOTE;
system("/bin/cp",$TEMP, $NOTEDB);
unlink $TEMP;
}
sub set_edit
{
my($this, $num, $note, $date) = @_;
my $address = ($num -1 ) * $sizeof;
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
seek(NOTE, $address, IO::Seekable::SEEK_SET);
my $n = uen($note);
my $t = uen($date);
my $buffer = pack($typedef, $num, $n, $t);
print NOTE $buffer;
flock NOTE, LOCK_UN;
close NOTE;
}
sub set_new
{
my($this, $num, $note, $date) = @_;
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, IO::Seekable::SEEK_END); # APPEND
my $n = uen($note);
my $t = uen($date);
my $buffer = pack($typedef, $num, $n, $t);
print NOTE $buffer;
flock NOTE, LOCK_UN;
close NOTE;
}
sub set_del
{
my($this, $num) = @_;
my($note, $date, $T, $setnum, $buffer, $buff, $n);
$setnum = 1;
my $TEMP = "/tmp/note.$$"; # save temporarily in $TEMP
system("/bin/touch", $TEMP);
open TEMP, "+<$TEMP" or die "Could not open $TEMP($!)\n";
open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $sizeof)) {
($n, $note, $date) = unpack($typedef, $buffer);
$buff = pack($typedef, $setnum, $note, $date);
if($n != $num) {
seek(TEMP, 0, IO::Seekable::SEEK_END); # APPEND
print TEMP $buff;
}
else
{
$T = $date;
}
$setnum++;
}
close(TEMP);
flock NOTE, LOCK_UN;
close NOTE;
system("/bin/cp",$TEMP, $NOTEDB);
unlink $TEMP;
return "ERROR" if($T eq ""); # signal success!
}
sub uen
{
my($T);
$T = pack("u", $_[0]);
chomp $T;
return $T;
}
sub ude
{
my($T);
$T = unpack("u", $_[0]);
return $T;
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::binary - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object
$db = new NOTEDB("binary", "/home/tom/.notedb", 4096, 24);
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
=head1 DESCRIPTION
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a SQL database and one for a
binary file (note's own database-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

258
NOTEDB/mysql.pm Normal file
View File

@@ -0,0 +1,258 @@
#!/usr/bin/perl
use DBI;
use strict;
use Data::Dumper;
package NOTEDB;
# Globals:
my ($DB, $table, $fnum, $fnote, $fdate, $version);
$table = "note";
$fnum = "number";
$fnote = "note";
$fdate = "date";
$version = "(NOTEDB::mysql, 1.0)";
# prepare some std statements... #####################################################################
my $sql_getsingle = "SELECT $fnote,$fdate FROM $table WHERE $fnum = ?";
my $sql_all = "SELECT $fnum,$fnote,$fdate FROM $table";
my $sql_nextnum = "SELECT max($fnum) FROM $table";
my $sql_incrnum = "SELECT $fnum FROM $table ORDER BY $fnum";
my $sql_search = "SELECT DISTINCT $fnum,$fnote,$fdate FROM $table WHERE $fnote LIKE ?";
my $sql_setnum = "UPDATE $table SET $fnum = ? WHERE $fnum = ?";
my $sql_edit = "UPDATE $table SET $fnote = ?, $fdate = ? WHERE $fnum = ?";
my $sql_insertnew = "INSERT INTO $table VALUES (?, ?, ?)";
my $sql_del = "DELETE FROM $table WHERE $fnum = ?";
######################################################################################################
sub new
{
# no prototype, because of the bin-version, which takes only a filename!
my($this, $dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
my $database = "DBI:$dbdriver:$dbname;host=$dbhost";
$DB = DBI->connect($database, $dbuser, $dbpasswd) || die DBI->errstr();
# LOCK the database!
my $lock = $DB->prepare("LOCK TABLES $table WRITE") || die $DB->errstr();
$lock->execute() || die $DB->errstr();
return $self;
}
sub DESTROY
{
# clean the desk!
my $unlock = $DB->prepare("UNLOCK TABLES") || die $DB->errstr;
$unlock->execute() || die $DB->errstr();
$DB->disconnect || die $DB->errstr;
}
sub version {
return $version;
}
sub get_single
{
my($this, $num) = @_;
my($note, $date);
my $statement = $DB->prepare($sql_getsingle) || die $DB->errstr();
$statement->execute($num) || die $DB->errstr();
$statement->bind_columns(undef, \($note, $date)) || die $DB->errstr();
while($statement->fetch) {
return $note, $date;
}
}
sub get_all
{
my($this, $num, $note, $date, %res);
my $statement = $DB->prepare($sql_all) || die $DB->errstr();
$statement->execute || die $DB->errstr();
$statement->bind_columns(undef, \($num, $note, $date)) || die $DB->errstr();
while($statement->fetch) {
$res{$num}->{'note'} = $note;
$res{$num}->{'date'} = $date;
}
return %res;
}
sub get_nextnum
{
my($this, $num);
my $statement = $DB->prepare($sql_nextnum) || die $DB->errstr();
$statement->execute || die $DB->errstr();
$statement->bind_columns(undef, \($num)) || die $DB->errstr();
while($statement->fetch) {
return $num+1;
}
}
sub get_search
{
my($this, $searchstring) = @_;
my($num, $note, $date, %res);
$searchstring = "\%$searchstring\%";
my $statement = $DB->prepare($sql_search) || die $DB->errstr();
$statement->execute($searchstring) || die $DB->errstr();
$statement->bind_columns(undef, \($num, $note, $date)) || die $DB->errstr();
while($statement->fetch) {
$res{$num}->{'note'} = $note;
$res{$num}->{'date'} = $date;
}
return %res;
}
sub set_recountnums
{
my $this = shift;
my(@count, $i, $num, $setnum);
$setnum = 1;
my $statement = $DB->prepare($sql_incrnum) || die $DB->errstr();
my $sub_statement = $DB->prepare($sql_setnum) || die $DB->errstr();
$statement->execute || die $DB->errstr();
$statement->bind_columns(undef, \($num)) || die $DB->errstr();
while($statement->fetch) {
$sub_statement->execute($setnum,$num) || die $DB->errstr();
$setnum++;
}
}
sub set_edit
{
my($this, $num, $note, $date) = @_;
my $statement = $DB->prepare($sql_edit) || die $DB->errstr();
$note =~ s/'/\'/g;
$note =~ s/\\/\\\\/g;
$statement->execute($note, $date, $num) || die $DB->errstr();
}
sub set_new
{
my($this, $num, $note, $date) = @_;
my $statement = $DB->prepare($sql_insertnew) || die $DB->errstr();
$note =~ s/'/\'/g;
$note =~ s/\\/\\\\/g;
$statement->execute($num, $note, $date) || die $DB->errstr();
}
sub set_del
{
my($this, $num) = @_;
my($note, $date, $T);
my $stat = $DB->prepare($sql_getsingle) || die $DB->errstr();
$stat->execute($num) || die $DB->errstr();
$stat->bind_columns(undef, \($note, $date)) || die $DB->errstr();
while($stat->fetch) {
$T = $date;
}
my $statement = $DB->prepare($sql_del) || die $DB->errstr();
$statement->execute($num) || die $DB->errstr();
$this->set_recountnums();
return "ERROR" if($T eq ""); # signal success!
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::mysql - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object (the last 4 params are db table/field names)
$db = new NOTEDB("mysql","note","localhost","username","password","note","number","note","date");
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# recount all noteids starting by 1 (usefull after deleting one!)
$db->set_recountnums();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
=head1 DESCRIPTION
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a SQL database and one for a
binary file (note's own database-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

73
README
View File

@@ -1,4 +1,4 @@
note 0.7 by Thomas Linden, 08/03/2000
note 0.8 by Thomas Linden, 19/03/2000
Introduction
@@ -17,20 +17,15 @@ Introduction
sort your notes in different topics, which is usefull
if you have a lot of them.
There are now two version of note in one package:
o (binary) the binary version resists in the
subdirectory "binary-db".
It uses a binary file for data storage.
The format of this file will be described
later on.
o (mysql) the mysql version resists in the
subdirectory mysql-db. It uses a mysql
database as backend. There are some
special installation steps required in
order to run the mysql version which are
documented in the README within this
subdirectory.
There are currently two different database backends,
which you can use with note:
o NOTEDB::binary - this is the default backend
and uses a binary file to store your notes.
o NOTEDB::mysql - this backend uses a mysql
database to store your notes. You can switch
easily to another DBMS since this module uses
the Perl standard module "DBI" for database-
access. See below for more info on this topic!
Requirements
@@ -38,20 +33,22 @@ Requirements
You need the following things:
o perl installed (5.004x)
o The module IO::Seekable, which should be
o The module IO::Seekable and Fcntl, which should be
already installed with your perl distributuion.
o Mysql.pm if you want to use the mysql version.
o DBI module and DBI::mysql if you want to use the
mysql version.
Installation
============
Simple: Copy it to a place inside your $PATH,
probably as root. (for example to /usr/bin).
There is a script provided called "install.sh", which will
ask you a few questions about file destinations and database
backends. Simply answer this questions and it does the rest.
For installation instructions for the mysql version see
mysql-db/README.
For installation instructions for the mysql database installation
see mysql/README.
@@ -65,20 +62,19 @@ Configuration
about every available parameter.
Simply copy this file into your home-directory and name it
.noterc
If you decide not to use the default database backend (a binary
file), you will *need* a configuration!
Usage
=====
Usage of the mysql and binary version is similar, there
are only differences between the database backends of
each other.
If you don't know, how to run note, try "note -h" first.
It will tell you all available commandline options.
To create a new note, simply run "note". You can enter
the note (the length is by default limited to 1024 bytes,
the note (the length is by default limited to 4096 bytes,
which you can change from your config file).
End by typing a . on a line itself. note will tell you the
number of the note.
@@ -121,8 +117,8 @@ Usage
provides you the most functions of note.
You can also dump the contents of your note-database into a
ASCII-textfile. You can use this file later to import it into
your note-database. This is usefull, if you want quickly trans-
ASCII-textfile(-D). You can use this file later to import it into
your note-database(-I). This is usefull, if you want quickly trans-
fer your notes from one host to another (i.e. you could mail
your note-dump form your office to home and import it there
for further use).
@@ -141,12 +137,16 @@ Topics
(or whatever you prefer, set $TopicSep in your config! default is slash),
then note will consider it as the topic of this certain note. For examle:
/TodoList/
If you are using topics, no data after the topic is allowed, if there
is any text, note will consider it as a subtopic! Therefore, don't for-
get to put a newline after the topic-line.
If you are in interactive mode, you can "cd" to a different note simply
by typing it's name at the command-prompt. The list-command will only
show you notes under this topic. If you create a new note, it will auto-
magically inserted under the current topic (note will prepend the string
"/topicname/" to the text of your note).
by typing it's name at the command-prompt, or you can use the well-known
syntax "cd topic".
The list-command will only show you notes under this topic. If you create
a new note, it will automagically inserted under the current topic (note
will prepend the string "/topicname/" to the text of your note).
You can create at any time from any point a new topic. Just create a new
note and type the name of the new topic bordered by slashes (or $TopicSep)
@@ -197,7 +197,7 @@ Topics
Format of the notedb (binary version)
Format of the notedb (binary backend)
=====================================
The database where the notes are stored is a binary file of
@@ -217,7 +217,7 @@ Format of the notedb (binary version)
The note-database (mysql version)
The note-database (mysql backend)
=================================
The sql-database for the mysql version has the following design:
@@ -324,10 +324,11 @@ License
Author
======
Author and Copyright
====================
The author is Thomas Linden.
note is Copyright of Thomas Linden.
@@ -335,4 +336,4 @@ Author
Last changed
============
21.02.2000
19/03/2000

3
UPGRADE Normal file
View File

@@ -0,0 +1,3 @@
if you are upgrading an existing note installation,
you need to reedit your configfile, since there are now
some new required options!

View File

@@ -1 +1 @@
0.7
0.8

1214
bin/note Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,65 @@
# 0.7
# 0.8
# This is a sample config for the note script
# You do not need it, if you keep the values
# here unchanged.
# There are usefully defaults set in note itself.
#
# The default database backend is NOTEDB::binary.
#
# Copy it to your $HOME as .noterc
#
# IMPORTANT:
# If you previously used note 0.1 or 0.2 then
# you will already have such a file. This file
# is not compatible with the one for note 0.3 and higher!
# You have to delete it and to create a new one.
#
# This config has to be valid perl code. Therefore
# please be carefull!
# please be careful!
#
# You can contact me per email: <tom@daemon.de>
#
# Thomas Linden, 23/2000
# Thomas Linden, 19/03/2000
# Your home, better do not change it!
$HOME = $ENV{'HOME'};
# specify the path, where the NOTEDB directory
# resides
$libpath = "/usr/local/lib";
# you need to decide which database backend you want
# to use. Please refer to the corresponding documentation
# for closer information about the certain backend!
# Currently supported types: "binary" or "mysql".
$dbdriver = "binary";
# backend specific settings:
####### mysql ###############
# sql database settings.
$dbhost = ""; # mysql server (hostname)
$dbuser = ""; # mysql username
$dbpasswd = ""; # her password
$dbname = ""; # database name
$table = "note"; # Table and field names.
$fnum = "number";
$fnote = "note";
$fdate = "date";
######## end mysql ###########
####### binary db ##################
# The location of the note-database. If it does
# not exist, it will be created. Only if $driver = "binary"
$NOTEDB = $HOME . "/.notedb";
# Define the maximum bytes a note can have in a
# note-entry.
$MAX_NOTE = 4096;
# Define the maximum bytes a timestamp can have
# in a note-entry.
$MAX_TIME = 24;
####### end binary #################
# mysql database settings. leave them uncommented
# if you are not using the mysql version of note.
# $dbhost = ""; # mysql server (hostname)
# $dbuser = ""; # mysql username
# $dbpasswd = ""; # her password
# $dbname = ""; # database name
# $table = "note"; # Table and field names.
# $fnum = "number";
# $fnote = "note";
# $fdate = "date";
# uncomment this, if you want to run note always
# in interactive mode
@@ -62,40 +93,20 @@ $TOPIC = 1;
#$TopicSep = '/';
# Define the maximum bytes a note can have in a
# note-entry.
$MAX_NOTE = 1024;
# Define the maximum bytes a timestamp can have
# in a note-entry.
$MAX_TIME = 64;
# The maximum width for displaying a note.
$maxlen = 30;
# Your home, better do not change it!
$HOME = `echo \$HOME`;
chomp $HOME;
# The location of the note-database. If it does
# not exist, it will be created.
$NOTEDB = $HOME . "/.notedb";
# if $COLOR equals NO, then everything will be
# displayed with your default colors (mostly black)
$COLOR = "NO";
$COLOR = "YES";
# Color-definitions of the various fields. Will be
# ignored if $COLOR = "NO".
$BORDER_COLOR = "BLACK"; # Borders
$NUM_COLOR = "blue"; # Note number
$NOTE_COLOR = "magenta"; # The note itself
$NOTE_COLOR = "green"; # The note itself
$TIME_COLOR = "black"; # The time
$TOPIC_COLOR = "BLACK"; # The topic "prompt"

View File

@@ -1,19 +1,56 @@
#!/bin/sh
# installs note
# installer for note 0.8 >
echo "Welcome to note `cat VERSION` installation."
echo "the install script will ask you a view questions,"
echo "make sure to answer them correctly!"
# $Id: install.sh,v 1.1 2000/03/19 03:33:28 thomas Exp thomas $
die ()
{
MSG=$1
echo $MSG
exit 1
}
SRC=.
NOTEDB="$SRC/NOTEDB"
BIN="$SRC/bin"
echo "Enter the destination for the note perl modules [/usr/local/lib] :"
read LIBDIR
echo "Enter the destination for the note program [/usr/local/bin] :"
read BINDIR
if [ "${LIBDIR}" = "" ] ; then
LIBDIR=/usr/local/lib
fi
if [ "${BINDIR}" = "" ] ; then
BINDIR=/usr/local/bin
fi
if [ ! -d ${LIBDIR} ] ; then
mkdir -p ${LIBDIR} || die "Could not create ${LIBDIR}!"
fi
if [ ! -d ${BINDIR} ] ; then
mkdir -p ${BINDIR} || die "Could not create ${BINDIR}!"
fi
echo "Installing note ..."
cp -ri ${NOTEDB} ${LIBDIR} || die "Could not copy modules!"
cp -i "${BIN}/note" ${BINDIR} || die "Could not copy note script!"
chmod 755 ${BINDIR}/note
chmod 755 ${LIBDIR}/NOTEDB
chmod 644 ${LIBDIR}/NOTEDB/*
echo "done. Please copy ${SRC}/config/noterc to ~/.noterc"
echo "and edit it if you like. "
echo
/bin/echo -n "creating the note database..."
NAME="_note"
DBNAME="$USER$NAME"
echo "DBNAME=$DBNAME"
mysqladmin create $DBNAME
echo "done."
/bin/echo -n "creating the table structure using defaults..."
mysql $DBNAME < sql
echo "done."
echo "Thanks for using note 0.8!"

62
mysql/README Normal file
View File

@@ -0,0 +1,62 @@
README for the mysql database installation for note
Requirements
============
You need the following things:
o perl installed (5.004x)
o mysql database installed and running
o Mysql perlmodule (you can find it on
http://www.mysql.org) PLEASE NOTE:
It needs the Module "Mysql". The install.sh
script will install it for you directly from
CPAN if you like. Newer versions
are DBI, which you can also use to access
mysql databases. If you want to use it, you
have to rewrite the program. Please let me
know, if you did it :-)
o permissions to create a new database and
to write data to this database.
Installation
============
First, make sure all these things above are ok.
You can use the script "install.sh" to create a new
database and the table structure. You might edit
the script before running it.
If you are getting trouble, i.e. if you have not the
required permissions to do that, please make sure,
you can.
As user root, you have to give your user the
neccessary permissions. Please refer to the mysql
documentation, how to do that.
After that repeat the step above.
You can find a sample config file within the subdirectory
"config" named noterc. There are some special values
which you can use to connect to a different database
then the default.
install.sh will create the following database:
name: user_note
Maintable: note
Number: number(int 10)
Note: note(text)
Date: date(text)
You can use the file "permissions" as a template for
modifying a users permissions to her database. Please
note, that there are different version of mysql out
there with different access privilege systems, which
are not compatible, refer to the documentation shipped
with your mysql installation to learn, how many fields
are available and what they are for.
You may also take a look to:
http://www.mysql.org/Manual_chapter/manual_Privilege_system.html
This should be all.

33
mysql/install.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# installs note
# This is the installer for the mysql version only!
echo "Welcome to note `cat VERSION` installation."
echo "the install script will ask you a view questions,"
echo "make sure to answer them correctly!"
echo
/bin/echo -n "creating the note database..."
NAME="_note"
DBNAME="$USER$NAME"
echo "DBNAME=$DBNAME"
mysqladmin create $DBNAME
echo "done."
/bin/echo -n "creating the table structure using defaults..."
mysql $DBNAME < sql
echo "Shall I try to install the required MySQL driver from CPAN?"
read YESNO
case $YESNO in
"y" | "Y")
if [ $UID != 0 ] ; then
echo "You should be root for that!"
exit
fi
perl -MCPAN -e shell cpan> install mysql
;;
esac
echo "done."

2
mysql/permissions Normal file
View File

@@ -0,0 +1,2 @@
insert into user values
('localhost','','','Y','Y','Y','Y','Y','Y','N','N','N','N','N','N','N','Y');

8
mysql/sql Normal file
View File

@@ -0,0 +1,8 @@
CREATE TABLE note (
number int(10) DEFAULT '0' NOT NULL auto_increment,
note text,
date text,
PRIMARY KEY (number)
);
# sample grant statement:
#GRANT ALL PRIVILEGES ON tom_note TO tom@localhost IDENTIFIED BY 'password';