Dev Finding Things
Contents
Grepping through code
In the directory you want to search:
rgrep -i [search term] *
To output the results of that search into a file in your home directory:
rgrep -i [search term] * > ~/filename.txt
Directory Structure
An outline of a live site's directory structure, as created by running bootstrap.pl, can be found in Main development folder.
Managing the database schema
The database schema is managed by editing update-db-general.pl. Update-db-general.pl is organized roughly like this so:
- mark which tables are clustered (versus global)
- table creation, post-create table population, table deletion
- table alteration
Functions you may need to use:
- creating a new table
register_tablecreate( "tablename", <<'EOC'); CREATE TABLE tablename ( .... ) EOC
- drop a table
- remove the relevant register_tablecreate code
- drop the table if it exists already (for older installations)
register_tabledrop( "tablename" );
- adding a column to an existing table
- add the column to the register_tablecreate code, for new installations
- add this to the bottom of register_alter, for existing installations
# check that the column does not yet exist unless ( column_type( "tablename", "columname" ) ) { do_alter("tablename", "ALTER TABLE tablename ADD ..." ); }
- modifying a column in an existing table / modifying data in an existing table
Similar to adding a column, but instead of checking whether a table exists, you may want to check against index_name, table_relevant, column_type, e.g.,
if ( index_name( ... ) ) {}
- initialize a table with data from another table on table creation
post_create( "tablename", /*sql statements/code. Look at other examples in the file */ );
To update your database with your changes, run
$LJHOME/bin/upgrading/update-db.pl -r --innodb
Properties
Properties are listed in bin/upgrading/proplists.dat, broken down into three sections and listed alphabetically within those sections:
- userproplist (user properties)
- talkproplist (comment properties)
- logproplist (entry properties)
When removing, remove the property from the file, and also do a grep over the codebase to remove any code which uses this prop.
Translation strings
Translation strings are defined in a few different files:
- bin/upgrading/en.dat - central location for strings for the backend code, e.g., things in cgi-bin, hooks, widgets
- htdocs/page.bml.text - scattered throughout htdocs; partner to htdocs/page.bml
When removing a string, transfer it to deadphrases.dat. Deadphrases.dat lists phrases that are no longer in use, so that other installations can deactivate these strings as well when they update their code.
If the string you removed was from en.dat, put it into deadphrases as:
general prop.name.blah
If the string you removed is from a page, put it into deadphrases as:
general /page.bml.prop.name.blah
After making your changes, run
$LJHOME/bin/upgrading/texttool.pl load
to actually load the new/modified strings into your live environment.
Hooks
Hook implementations can be found in
Some hook documentation can be found in doc/raw/hooks.txt, but it is very outdated and incomplete, and probably should be ignored right now.
Memcache
A list of memcache keys can be found in doc/raw/memcache-keys.txt. You should update this if you add new memcache keys or change existing behavior.
Styles
- dw-free/bin/upgrading/s2layers.dat, dw-nonfree/bin/upgrading/s2layers-local.dat
Defines system layers + layer types + layer parents
- bin/upgrading/s2layers/$themename/layout.s2, bin/upgrading/s2layers/$themename/themes.s2
Contains actual layout layers, list of themes
- dw-free/cgi-bin/LJ/S2Themes.pm, dw-nonfree/cgi-bin/LJ/S2Themes-local.pm
Handles some logic surrounding themes, contains list of default themes for each layout
- cgi-bin/S2Themes/$layout
Contains logic for /customize/ and /customize/options.bml pages. Arranges properties into propgroups, puts themes into categories, contains designer