init
This commit is contained in:
16
livejournal/htdocs/styles/browse/index.html
Executable file
16
livejournal/htdocs/styles/browse/index.html
Executable file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Style Browser</title>
|
||||
</head>
|
||||
|
||||
<frameset cols="200,*">
|
||||
<frameset rows="100,*">
|
||||
<frame name="start" src="start.bml">
|
||||
<frame name="links" src="links.bml">
|
||||
</frameset>
|
||||
<frame name="main" src="instructions.bml">
|
||||
</frameset>
|
||||
|
||||
</html><!-- <LJDEP>
|
||||
link: htdocs/styles/browse/start.bml, htdocs/styles/browse/blank.bml, htdocs/styles/browse/instructions.bml
|
||||
</LJDEP> -->
|
||||
12
livejournal/htdocs/styles/browse/instructions.bml
Executable file
12
livejournal/htdocs/styles/browse/instructions.bml
Executable file
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Style Browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Style Browser</h1>
|
||||
<p>Enter a username in the box on the left and click "Preview" to see a list of that users'
|
||||
public styles. In the list, click on the style name to view what the style looks like, or
|
||||
click the dash to view style information.</p>
|
||||
</body>
|
||||
</html><!-- <LJDEP>
|
||||
</LJDEP> -->
|
||||
55
livejournal/htdocs/styles/browse/links.bml
Executable file
55
livejournal/htdocs/styles/browse/links.bml
Executable file
@@ -0,0 +1,55 @@
|
||||
<base target=_top>
|
||||
<?_code
|
||||
{
|
||||
use strict;
|
||||
use vars qw(%GET);
|
||||
|
||||
my $user = LJ::canonical_username($GET{'user'});
|
||||
return "Enter a username." unless $user;
|
||||
|
||||
my $remote = LJ::get_remote();
|
||||
my $dispuser = $remote ? $remote->{'user'} : $user;
|
||||
my $styu = LJ::load_user($user);
|
||||
my $styles;
|
||||
if ($user eq 'system') {
|
||||
$styles = LJ::S1::get_public_styles();
|
||||
} else {
|
||||
$styles = LJ::S1::get_user_styles($user);
|
||||
}
|
||||
|
||||
my $admin = $remote &&
|
||||
(LJ::check_priv($remote, 'canview', 'styles') ||
|
||||
LJ::check_priv($remote, 'canview', '*'));
|
||||
|
||||
my ($dday,$dmon,$dyear) = (localtime(time))[3..5];
|
||||
$dyear+=1900; $dmon++;
|
||||
my %extra = ( 'day' => "&month=$dmon&day=$dday&year=$dyear" );
|
||||
|
||||
my $ret = "Styles for " . LJ::ljuser($user) . ":<br /><br />";
|
||||
|
||||
my $last;
|
||||
STY:
|
||||
foreach my $sty (sort { $a->{'type'} cmp $b->{'type'} || $a->{'styledes'} cmp $b->{'styledes'} }
|
||||
values %$styles) {
|
||||
|
||||
next STY unless $sty->{is_public} eq 'Y' || # public is always visible
|
||||
LJ::u_equals($remote, $styu) || # yours are visible to you
|
||||
LJ::can_manage($remote, $styu) ||# you can view things you manage
|
||||
$admin; # you have appropriate canview
|
||||
|
||||
if ($last ne $LJ::viewinfo{$sty->{'type'}}->{'des'}) {
|
||||
$last = $LJ::viewinfo{$sty->{'type'}}->{'des'};
|
||||
$ret .= "<b>$last</b><br />\n";
|
||||
}
|
||||
|
||||
$ret .= "<nobr> [<a target='main' href='styleinfo.bml?styleid=$sty->{'styleid'}'>info</a>] ";
|
||||
$ret .= "<a target='main' href='/customview.cgi?styleid=$sty->{'styleid'}&user=$dispuser&";
|
||||
$ret .= "nooverride=1$extra{$sty->{'type'}}'>$sty->{'styledes'}</a></nobr><br />\n";
|
||||
}
|
||||
|
||||
$ret .= ".";
|
||||
return $ret;
|
||||
}
|
||||
_code?><?_c <LJDEP>
|
||||
link: htdocs/styles/browse/styleinfo.bml, htdocs/customview.cgi
|
||||
</LJDEP> _c?>
|
||||
9
livejournal/htdocs/styles/browse/start.bml
Executable file
9
livejournal/htdocs/styles/browse/start.bml
Executable file
@@ -0,0 +1,9 @@
|
||||
<FORM TARGET="links" ACTION="links.bml" METHOD=GET>
|
||||
View styles of user:
|
||||
<INPUT NAME="user" VALUE="system" SIZE=15 MAXLENGTH=15>
|
||||
<BR>
|
||||
|
||||
<INPUT TYPE="SUBMIT" VALUE="Preview">
|
||||
</FORM> <?_c <LJDEP>
|
||||
form: htdocs/styles/browse/links.bml
|
||||
</LJDEP> _c?>
|
||||
45
livejournal/htdocs/styles/browse/styleinfo.bml
Executable file
45
livejournal/htdocs/styles/browse/styleinfo.bml
Executable file
@@ -0,0 +1,45 @@
|
||||
<?_code
|
||||
|
||||
my $styleid = $FORM{'styleid'}+0;
|
||||
my $remote = LJ::get_remote();
|
||||
|
||||
my $sty = LJ::S1::get_style($styleid);
|
||||
my $styu = LJ::load_user($sty->{user}) if $sty; # if $sty so we don't auto-vivify!
|
||||
return "Style $styleid does not exist or is not public."
|
||||
unless $sty &&
|
||||
($sty->{is_public} eq 'Y' || # straight up public
|
||||
LJ::u_equals($remote, $styu) || # is this your account?
|
||||
LJ::can_manage($remote, $styu) || # how about your community?
|
||||
LJ::check_priv($remote, 'canview', 'styles') || # can you see private styles?
|
||||
LJ::check_priv($remote, 'canview', '*')); # or maybe you can see everything
|
||||
|
||||
my $ret = "";
|
||||
$ret .= "<H1>Style Info</H1>\n";
|
||||
|
||||
$ret .= "<DL>\n";
|
||||
$ret .= "<DT><B>Author</B><DD><A TARGET=_top HREF=\"$LJ::SITEROOT/userinfo.bml?user=$sty->{'user'}\">$sty->{'user'}</A>\n";
|
||||
$ret .= "<DT><B>Style Description</B><DD>$sty->{'styledes'}<BR>\n";
|
||||
$ret .= "<DT><B>Last Updated</B><DD>$sty->{'lastupdate'}<BR>\n";
|
||||
$ret .= "<DT><B>View Type</B><DD>$sty->{'type'}<BR>\n";
|
||||
$ret .= "<DT><B>Public?</B><DD>$sty->{'is_public'}<BR>\n";
|
||||
$ret .= "<DT><B>Embeddable?</B><DD>$sty->{'is_embedded'}<BR>\n";
|
||||
$ret .= "<DT><B>Color-free? (only uses color themes, not fixed colors)</B><DD>$sty->{'is_colorfree'}<BR>\n";
|
||||
$ret .= "</DL>";
|
||||
|
||||
my %vars;
|
||||
LJ::parse_vars(\$sty->{'formatdata'}, \%vars);
|
||||
|
||||
$ret .= "<H1>Style Variables</H1>\n";
|
||||
|
||||
foreach my $v (sort keys %vars) {
|
||||
$ret .= "<H2>$v</H2>\n";
|
||||
my $val = LJ::ehtml($vars{$v});
|
||||
$val =~ s/\n/<BR>\n/g;
|
||||
$ret .= $val;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
_code?><?_c <LJDEP>
|
||||
link: htdocs/userinfo.bml
|
||||
</LJDEP> _c?>
|
||||
64
livejournal/htdocs/styles/create.bml
Executable file
64
livejournal/htdocs/styles/create.bml
Executable file
@@ -0,0 +1,64 @@
|
||||
<?page
|
||||
title=><?_ml .title _ml?>
|
||||
body<=
|
||||
|
||||
<?_code
|
||||
{
|
||||
use strict;
|
||||
use vars qw(%GET);
|
||||
|
||||
LJ::set_active_crumb('createstyle');
|
||||
|
||||
my $remote = LJ::get_remote();
|
||||
return LJ::bad_input($ML{'error.noremote'})
|
||||
unless $remote;
|
||||
|
||||
my $ret;
|
||||
my $authas = $GET{'authas'} || $remote->{'user'};
|
||||
my $getextra = $authas ne $remote->{'user'} ? "?authas=$authas" : "";
|
||||
|
||||
# no authentication needs to be done on this page, it's just a form anyway
|
||||
|
||||
# user switcher
|
||||
$ret .= "<form action='create.bml' method='get'>\n";
|
||||
$ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} });
|
||||
$ret .= "</form>\n\n";
|
||||
|
||||
$ret .= "<form action='create_do.bml$getextra' method='post'>\n";
|
||||
|
||||
# main form
|
||||
$ret .= "<?h1 $ML{'.createstyle.head'} h1?>\n";
|
||||
$ret .= "<?p $ML{'.createstyle.text'} p?>";
|
||||
|
||||
$ret .= "<?h1 $ML{'.selecttype.head'} h1?>\n";
|
||||
$ret .= "<?p $ML{'.selecttype.text'} p?>\n";
|
||||
|
||||
my $pubstyles = LJ::S1::get_public_styles();
|
||||
my %styles;
|
||||
push @{$styles{$_->{'type'}}}, $_ foreach values %$pubstyles;
|
||||
|
||||
foreach my $view (@LJ::views) {
|
||||
$ret .= "<p>" . LJ::html_check({ 'type' => 'radio', 'name' => 'type', 'id' => "type-$view", 'value' => $view });
|
||||
$ret .= "<b><label for='type-$view'>$LJ::viewinfo{$view}->{'des'}</label></b></p>\n";
|
||||
$ret .= "<div style='margin: 10px 0 20px 30px;'>$ML{'.choosebase'}<br />\n";
|
||||
$ret .= LJ::html_select({ 'name' => "base_$view" },
|
||||
'', $ML{'.noneorother'},
|
||||
map { $_->{'styleid'}, $_->{'styledes'} }
|
||||
sort { $a->{'styledes'} cmp $b->{'styledes'} } @{$styles{$view}} );
|
||||
$ret .= "<br />$ML{'.enterstyleid'} ";
|
||||
$ret .= LJ::html_text({ 'name' => "basenum_$view", 'size' => '5', 'maxlength' => '10' }) . "</div>\n";
|
||||
}
|
||||
|
||||
$ret .= "<?standout " . LJ::html_submit(undef, $ML{'.submit'}) . " standout?>\n";
|
||||
$ret .= "</form>\n";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
_code?>
|
||||
|
||||
<=body
|
||||
page?><?_c <LJDEP>
|
||||
link: htdocs/developer/embedding.bml, htdocs/developer/views.bml
|
||||
link: htdocs/paidaccounts/index.bml
|
||||
post: htdocs/styles/create_do.bml
|
||||
</LJDEP> _c?>
|
||||
101
livejournal/htdocs/styles/create_do.bml
Executable file
101
livejournal/htdocs/styles/create_do.bml
Executable file
@@ -0,0 +1,101 @@
|
||||
<?page
|
||||
title=><?_ml .title _ml?>
|
||||
body<=
|
||||
|
||||
<?_code
|
||||
{
|
||||
use strict;
|
||||
use vars qw(%GET %POST);
|
||||
|
||||
LJ::set_active_crumb('createstyle');
|
||||
|
||||
return LJ::server_down_html() if $LJ::SERVER_DOWN;
|
||||
return BML::redirect("create.bml") unless LJ::did_post();
|
||||
|
||||
my $remote = LJ::get_remote();
|
||||
return "<?needlogin?>"
|
||||
unless $remote;
|
||||
|
||||
my $authas = $GET{'authas'} || $remote->{'user'};
|
||||
my $u = LJ::get_authas_user($authas);
|
||||
return LJ::bad_input($ML{'error.authinvalid'})
|
||||
unless $u;
|
||||
|
||||
unless (LJ::get_cap($u, "styles")) {
|
||||
return LJ::bad_input($ML{'.error.accounttype'});
|
||||
}
|
||||
|
||||
# error check submission
|
||||
return LJ::bad_input($ML{'.error.invalidview'})
|
||||
unless $POST{'type'} && defined $LJ::viewinfo{$POST{'type'}};
|
||||
|
||||
my $view = $POST{'type'};
|
||||
my $base = "";
|
||||
my $baseid = $POST{"base_$view"} || $POST{"basenum_$view"};
|
||||
|
||||
if ($baseid) {
|
||||
my $rec = LJ::S1::get_style($baseid);
|
||||
|
||||
return LJ::bad_input(BML::ml('.error.stylenotfound',{ 'baseid' => $baseid, }))
|
||||
unless $rec && $rec->{'type'} eq $view;
|
||||
|
||||
return LJ::bad_input(BML::ml('.error.stylenotpublic',{ 'baseid' => $baseid, }))
|
||||
unless $rec->{'is_public'} eq "Y" || $rec->{'user'} eq $u->{'user'};
|
||||
|
||||
# they're allowed to base on this style
|
||||
$base = $rec->{'formatdata'};
|
||||
}
|
||||
|
||||
### start of output
|
||||
|
||||
my $ret = "";
|
||||
my $des = "$u->{'user'}-$view-new";
|
||||
|
||||
# let's see if they accidentally double-clicked:
|
||||
my $double_clicked = 0;
|
||||
my $new_id = 0;
|
||||
my $oldstyle = LJ::S1::check_dup_style($u, $view, $des);
|
||||
|
||||
# closure to show edit form
|
||||
my $editform = sub {
|
||||
my $getextra = "?authas=$authas" if $u->{'user'} ne $remote->{'user'};
|
||||
return "<div align='center'><form method='post' action='$LJ::SITEROOT/styles/edit_do.bml$getextra'>\n" .
|
||||
LJ::html_hidden('mode', 'editstyle', 'styleid', $_[0]) . "\n" .
|
||||
LJ::html_submit(undef, $ML{'.editstyle'}) . "</form></div>\n";
|
||||
};
|
||||
|
||||
if ($oldstyle) {
|
||||
if ($oldstyle->{'formatdata'} eq $base) {
|
||||
# the user double-clicked
|
||||
$double_clicked = 1;
|
||||
$new_id = $oldstyle->{'styleid'};
|
||||
|
||||
} else {
|
||||
$ret .= "<?h1 $ML{'Error'} h1?>" .
|
||||
"<?p " . BML::ml('.styleexists',{ 'des' => $des, 'view' => $view, }) . " p?>";
|
||||
|
||||
$ret .= $editform->($oldstyle->{'styleid'});
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
unless ($double_clicked) {
|
||||
$new_id = LJ::S1::create_style($u,
|
||||
{ 'styledes' => $des,
|
||||
'type' => $view,
|
||||
'formatdata' => $base });
|
||||
return "<?h1 $ML{'Error'} h1?><?p $ML{'error.nodb'} p?>"
|
||||
unless defined $new_id;
|
||||
}
|
||||
|
||||
$ret .= "<?h1 $ML{'.success.head'} h1?><?p " . BML::ml('.success.text',{ 'des' => $des, }) . " p?>\n";
|
||||
|
||||
$ret .= $editform->($new_id);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
_code?>
|
||||
<=body
|
||||
page?><?_c <LJDEP>
|
||||
post: htdocs/styles/edit_do.bml
|
||||
</LJDEP> _c?>
|
||||
66
livejournal/htdocs/styles/edit.bml
Executable file
66
livejournal/htdocs/styles/edit.bml
Executable file
@@ -0,0 +1,66 @@
|
||||
<?page
|
||||
title=>Edit Style
|
||||
|
||||
body<=
|
||||
<?_code
|
||||
{
|
||||
use strict;
|
||||
use vars qw(%GET);
|
||||
|
||||
LJ::set_active_crumb('editstyle');
|
||||
|
||||
my $remote = LJ::get_remote();
|
||||
return LJ::bad_input($ML{'error.noremote'})
|
||||
unless $remote;
|
||||
|
||||
my $authas = $GET{'authas'} || $remote->{'user'};
|
||||
my $u = LJ::get_authas_user($authas);
|
||||
return LJ::bad_input("You could not be authenticated as the specified user.")
|
||||
unless $u;
|
||||
|
||||
# authenticated
|
||||
my $ret;
|
||||
|
||||
# user switcher
|
||||
$ret .= "<form action='edit.bml' method='get'>\n";
|
||||
$ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} });
|
||||
$ret .= "</form>\n\n";
|
||||
|
||||
my $getextra = $u->{'user'} ne $remote->{'user'} ? "?authas=$authas" : "";
|
||||
|
||||
$ret .= "<?h1 Edit which style? h1?>\n";
|
||||
$ret .= "<?p After you <a href='$LJ::SITEROOT/styles/create.bml'><b>create a style</b></a>, you can edit it here. ";
|
||||
$ret .= "To read more about the style system, go <a href='$LJ::SITEROOT/developer/styles.bml'>here</a>. p?>\n\n";
|
||||
$ret .= "<?p You own the following styles. Choose which one you want to modify. p?>\n";
|
||||
$ret .= "<form method='post' action='edit_do.bml$getextra'>";
|
||||
$ret .= "<?standout Pick a style:<br />";
|
||||
|
||||
my $styles = LJ::S1::get_user_styles($u);
|
||||
|
||||
my @list = map { $_->{'styleid'}, "$_->{'type'}($_->{'styleid'}): $_->{'styledes'}" }
|
||||
sort { $a->{'styledes'} cmp $b->{'styledes'} } values %$styles;
|
||||
@list = @list ? @list : ('', 'no styles');
|
||||
|
||||
$ret .= LJ::html_select({ 'name' => 'styleid', 'size' => '10', 'style' => 'width: 100%;' },
|
||||
@list) . "<br />\n";
|
||||
|
||||
$ret .= "<div style='margin-top: 3px;'>Action: ";
|
||||
$ret .= LJ::html_select({ 'name' => 'ide' },
|
||||
'v2', 'Edit in Easy Mode',
|
||||
'v1', 'Edit in Raw Mode (Old)',
|
||||
'delete', 'Delete this style!' ) . "</div>\n";
|
||||
|
||||
$ret .= "<div align='center' style='margin-top: 5px;'>";
|
||||
$ret .= LJ::html_submit(undef, "Proceed", { 'disabled' => ! @list });
|
||||
$ret .= "</div> standout?>\n";
|
||||
$ret .= "</form>\n";
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
_code?>
|
||||
<=body
|
||||
page?><?_c <LJDEP>
|
||||
link: htdocs/styles/create.bml, htdocs/developer/styles.bml
|
||||
post: htdocs/styles/edit_do.bml
|
||||
</LJDEP> _c?>
|
||||
316
livejournal/htdocs/styles/edit_do.bml
Executable file
316
livejournal/htdocs/styles/edit_do.bml
Executable file
@@ -0,0 +1,316 @@
|
||||
<?page
|
||||
title=>Edit Style
|
||||
body<=
|
||||
|
||||
<?_code
|
||||
{
|
||||
use strict;
|
||||
use vars qw(%GET %POST);
|
||||
|
||||
LJ::set_active_crumb('editstyle');
|
||||
|
||||
return LJ::server_down_html() if $LJ::SERVER_DOWN;
|
||||
|
||||
# authenticate user
|
||||
my $remote = LJ::get_remote();
|
||||
return LJ::bad_input($ML{'error.noremote'})
|
||||
unless $remote;
|
||||
|
||||
my $authas = $GET{'authas'} || $remote->{'user'};
|
||||
my $u = LJ::get_authas_user($authas);
|
||||
return LJ::bad_input("You could not be authenticated as the specified user")
|
||||
unless $u;
|
||||
|
||||
# check styles cap
|
||||
return LJ::bad_input("Your account type doesn't permit you to modify styles.")
|
||||
unless LJ::get_cap($u, "styles");
|
||||
|
||||
# get a style object
|
||||
my $styleid = $POST{'styleid'}+0;
|
||||
my $style = LJ::S1::get_style($styleid);
|
||||
return LJ::bad_input("The requested style does not exist.")
|
||||
unless $style;
|
||||
|
||||
# some static data
|
||||
my @style_opts = (
|
||||
{ 'code' => "is_public",
|
||||
'title' => 'Public?',
|
||||
'des' => "Mark this style public if you want other people to be able to use it or copy it." },
|
||||
{ 'code' => "is_embedded",
|
||||
'title' => 'Embedded?',
|
||||
'des' => "Is this style designed to be embedded in somebody's homepage? Check if so, otherwise it's a full page style." },
|
||||
{ 'code' => "is_colorfree",
|
||||
'title' => 'Color Free?',
|
||||
'des' => "A style is color-free if it does not contain any hard-coded color tags, but only uses the generic color codes listed in the table below." },
|
||||
);
|
||||
my @style_transforms = (
|
||||
{ 'trans' => 'lc',
|
||||
'des' => "Lower case." },
|
||||
{ 'trans' => 'uc',
|
||||
'des' => "Upper case." },
|
||||
{ 'trans' => 'ue',
|
||||
'des' => "URL-Encode. Turn spaces to +, and all weird characters to <tt>%hh</tt>, the hex representation. This is useful for building data files to be used in Flash-4 movies." },
|
||||
{ 'trans' => 'xe',
|
||||
'des' => "XML-Encode. Makes value acceptable for use in an XML attribute or element. Escapes ampersands, angle brackets, and both types of quotes. Does <i>not</i> however, escape ]]>, so don't use CDATA elements." },
|
||||
{ 'trans' => 'color',
|
||||
'des' => "A weird transform that handles color codes. See the color code table." },
|
||||
{ 'trans' => 'cons',
|
||||
'des' => "Access site constants. Currently supported are 'siteroot', 'sitename', and 'img' (the image root). Example use: %%cons:img%%/icon_protected.gif" },
|
||||
{ 'trans' => 'ljuser',
|
||||
'des' => "Transform the variable as if it were surrounded by <lj user=%%variable%%>. ex: %%ljuser:username%%" },
|
||||
{ 'trans' => 'ljcomm',
|
||||
'des' => "Transform the variable as if it were surrounded by <lj comm=%%variable%%>. ex: %%ljcomm:username%%" },
|
||||
{ 'trans' => 'userurl',
|
||||
'des' => 'Takes in a username and transforms it into a link to their journal.' },
|
||||
);
|
||||
|
||||
# construct ide and mode variables
|
||||
my $ide = $POST{'ide'};
|
||||
my $mode = $POST{'mode'} || 'editstyle';
|
||||
if ($mode eq 'editstyle') {
|
||||
if ($ide eq 'delete') {
|
||||
$mode = 'delete';
|
||||
} else {
|
||||
$ide = $ide eq 'v1' ? 'v1' : 'v2';
|
||||
$mode = 'editstyle';
|
||||
}
|
||||
}
|
||||
|
||||
### start of output
|
||||
|
||||
my $ret = "";
|
||||
|
||||
# pass authas arguments in forms if necessary
|
||||
my $getextra = "?authas=$authas" if $authas ne $remote->{'user'};
|
||||
|
||||
# delete confirmation
|
||||
if ($mode eq "delete") {
|
||||
$ret .= "<?h1 Are you sure? h1?><?p Are you sure you want to delete <b>$style->{'styledes'}</b>? If so, press the button below. This will temporarily break your journal if you're using this style, until you select a different style to use. p?>";
|
||||
|
||||
$ret .= "<form method='post' action='edit_do.bml$getextra'>";
|
||||
$ret .= LJ::html_hidden("mode", "delete_confirm", "styleid", $styleid);
|
||||
$ret .= "<p align='center'>" . LJ::html_submit(undef, "Yes, delete it!") . "</p></form>\n";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# process delete
|
||||
if ($mode eq "delete_confirm") {
|
||||
|
||||
LJ::S1::delete_style($styleid);
|
||||
return "<?h1 Deleted h1?><?p The style has been deleted. You can view your current list of styles " .
|
||||
"<a href='edit.bml$getextra'>here</a>. p?>";
|
||||
}
|
||||
|
||||
# editing a style
|
||||
if ($mode eq "editstyle") {
|
||||
$ret .= "<?h1 Edit Style h1?><?p Make any desired changes and press \"Save\" when done. p?>\n";
|
||||
$ret .= "<div style='width: 90%'><form method='post' action='edit_do.bml$getextra'>";
|
||||
$ret .= LJ::html_hidden("mode", "savechanges", "styleid", $styleid, "ide", $ide);
|
||||
|
||||
$ret .= "<table border='1' cellspacing='1' cellpadding='2' style='margin-bottom: 20px;'>\n";
|
||||
$ret .= "<tr><td bgcolor='#d0d0d0'><b>Style View Type:</b></td><td><i>$LJ::viewinfo{$style->{'type'}}->{'des'}</i> -- <b>$style->{'type'}</b></td></tr>\n";
|
||||
$ret .= "<tr><td bgcolor='#d0d0d0'><b>Style ID Number:</b></td><td><b>$style->{'styleid'}</b>";
|
||||
|
||||
my $extravars = "&nocache=1" if $style->{'opt_cache'} eq "Y";
|
||||
if ($style->{'type'} eq 'day') {
|
||||
my ($curmday, $curmon, $curyear) = (localtime(time))[3..5];
|
||||
$extravars .= sprintf("&day=%02d&month=%02d&year=%04d",
|
||||
$curmday, $curmon+1, $curyear+1900);
|
||||
}
|
||||
$ret .= " <a target='preview' href=\"$LJ::SITEROOT/customview.cgi?username=$u->{'user'}&styleid=$styleid$extravars\">[Preview Current Style]</a> (must save below to see your changes, keep this window open and reload it whenever you save)";
|
||||
$ret .= "</td></tr>\n";
|
||||
|
||||
$ret .= "<tr><td bgcolor='#d0d0d0'><b>Style Description:</b></td><td>";
|
||||
$ret .= LJ::html_text({ 'name' => 'styledes', 'value' => $style->{'styledes'},
|
||||
'size' => '50', 'maxlength' => '50' });
|
||||
$ret .= "</td></tr>\n";
|
||||
|
||||
$ret .= "<tr><td bgcolor='#d0d0d0'><b>Style Options:</b></td><td><table>\n";
|
||||
foreach my $opt (@style_opts) {
|
||||
$ret .= "<tr valign='top'><td>";
|
||||
$ret .= LJ::html_check({ 'type' => 'check','name' => $opt->{'code'}, 'id' => $opt->{'code'},
|
||||
'selected' => $style->{$opt->{'code'}} eq 'Y' });
|
||||
|
||||
$ret .= "</td><td><b><label for='$opt->{'code'}'>$opt->{'title'}</label></b><br />$opt->{'des'}</td></tr>";
|
||||
}
|
||||
$ret .= "</table></td></tr>\n";
|
||||
|
||||
$ret .= "</table>\n";
|
||||
|
||||
# color code instructions
|
||||
$ret .= "<?h1 Color Codes h1?><?p When designing a style, it's always best to avoid hard-coding colors in if possible. That way, if you get bored of your colors you can change them at one place (the modify journal page) and it'll affect all your styles where you use that color code. Obviously, if you need to use special images in your style, you may have to hard-code certain colors, but try to use them when you can. It's your call. <b>The following color codes can be used in any variable below that contains HTML:</b> p?>";
|
||||
|
||||
$ret .= "<p align='center'><table cellpadding='2' border='1' cellspacing='1'><tr bgcolor='#d0d0d0'><td>Code</td><td>Description</td></tr>\n";
|
||||
foreach my $col (@LJ::S1::themecoltypes) {
|
||||
$ret .= "<tr><td><tt>%%color:<b>$col->[0]</b>%%</tt></td><td>$col->[1]</td></tr>\n";
|
||||
}
|
||||
$ret .= "</table></p>\n";
|
||||
|
||||
# transform instructions
|
||||
$ret .= "<?h1 Transforms h1?><?p What if you want to use a property but don't like its formatting? Any property can be transformed 0 or more times by transform rules. Say you want to use <tt>%%monlong%%</tt> (March, April, May, etc...) but you don't like that the default has those upper case initial letters. You can apply the <b><tt>lc</tt></b> (lowercase) transform to it: <b><tt>%%lc:monlong%%</tt></b>. Transform are applied in order from the right to the left, so if you went <tt>%%a:b:c:d:property%%</tt>, <i>d</i> would be applied first. Here are a list of the supported transforms: p?>";
|
||||
|
||||
$ret .= "<p align='center'><table width='75%' cellpadding='2' border='1' cellspacing='1'><tr bgcolor='#d0d0d0'><td>Transform</td><td>Description</td></tr>\n";
|
||||
foreach (@style_transforms) {
|
||||
$ret .= "<tr><td><tt>$_->{'trans'}</tt></td><td>$_->{'des'}</td></tr>\n";
|
||||
}
|
||||
$ret .= "</table></p>\n";
|
||||
|
||||
### customizable vars section
|
||||
|
||||
# load variables from file
|
||||
my @vars;
|
||||
LJ::load_objects_from_file("vars.dat", \@vars);
|
||||
|
||||
# build hash of relevant variables
|
||||
my %var;
|
||||
foreach my $v (sort { $a->{'name'} cmp $b->{'name'} } @vars) {
|
||||
next unless ($v->{'props'}->{'scope'} =~ /\b$style->{'type'}\b/);
|
||||
$var{$v->{'name'}} = $v;
|
||||
}
|
||||
|
||||
# ide version 2 section
|
||||
if ($ide eq "v2") {
|
||||
|
||||
# closure to make variable edit fields
|
||||
my $make_edit_fields = sub {
|
||||
my ($self, $vars, $marked, @fields) = @_;
|
||||
foreach my $f (@fields) {
|
||||
next if ($marked->{$f}++);
|
||||
my $prop = $vars->{$f}->{'props'};
|
||||
$self->($self, $vars, $marked, split(/\s*,\s*/, $prop->{'deps'}));
|
||||
my $des = $prop->{'des'};
|
||||
$des =~ s/\[var\[(\S+?)\]\]/<a href="#$1">$1<\/a>/g;
|
||||
$des =~ s/\[view\[(\S+?)\]\]/$1/g;
|
||||
$des =~ s/%%\S+?%%/<tt>$&<\/tt>/g;
|
||||
|
||||
$ret .= "<p><a name='$f'><font size='+1'><tt><b>$f</b></tt></font><br />$des</p>\n";
|
||||
|
||||
if (defined $prop->{'props'}) {
|
||||
$ret .= "<p><table cellspacing='1' border='1' cellpadding='2'>\n";
|
||||
foreach my $p (@{$prop->{'props'}}) {
|
||||
$p->{'props'}->{'des'} =~ s/\[var\[(\S+?)\]\]/<a href="#$1">$1<\/a>/g;
|
||||
$p->{'props'}->{'des'} =~ s/\[view\[(\S+?)\]\]/$1/g;
|
||||
$p->{'props'}->{'des'} =~ s/%%\S+?%%/<tt>$&<\/tt>/g;
|
||||
$ret .= "<tr valign='top'><td bgcolor='#d0d0d0' align='right'><b>$p->{'name'}</b></td>\n";
|
||||
$ret .= "<td>$p->{'props'}->{'des'} ";
|
||||
if ($p->{'props'}->{'min'} > 0) {
|
||||
$ret .= "<font color='#ff0000'>[required]</font>";
|
||||
}
|
||||
$ret .= "</td></tr>\n";
|
||||
}
|
||||
$ret .= "</table></p>\n";
|
||||
}
|
||||
|
||||
my $editrows = $prop->{'editrows'} || 5;
|
||||
my $editcols = $prop->{'editcols'} || 70;
|
||||
|
||||
$ret .= "<p>";
|
||||
if ($vars->{$f}->{'props'}->{'override'} eq "only") {
|
||||
$ret .= "<span style='background-color: #ffff00'><b>Override only.</b></span> Only end-users may override this. You cannot define it in a style.";
|
||||
} else {
|
||||
my %stylevar = ();
|
||||
LJ::parse_vars(\$style->{'formatdata'}, \%stylevar);
|
||||
|
||||
if ($editrows == 1) {
|
||||
$ret .= LJ::html_text({ 'name' => "var:$f", 'value' => $stylevar{$f},
|
||||
'size' => $editcols, 'maxlength' => '255' });
|
||||
} else {
|
||||
$ret .= LJ::html_textarea({ 'name' => "var:$f", 'value' => $stylevar{$f},
|
||||
'wrap' => 'soft', 'rows' => $editrows, 'cols' => $editcols,
|
||||
'style' => 'width: 100%;' });
|
||||
}
|
||||
}
|
||||
$ret .= "</p>";
|
||||
$ret .= "<?hr?>\n";
|
||||
}
|
||||
}; # end closure
|
||||
|
||||
# display edit form
|
||||
$ret .= "<?h1 Customizable Variables h1?>";
|
||||
my %mark = ();
|
||||
$make_edit_fields->($make_edit_fields, \%var, \%mark, uc("$style->{'type'}_PAGE"), keys %var);
|
||||
}
|
||||
|
||||
# ide version 1 section
|
||||
if ($ide eq "v1") {
|
||||
|
||||
# show a big textarea for them to use
|
||||
$ret .= "<p><b>Style Variables:</b> <a target='_blank' href='/developer/views.bml#$style->{'type'}'>(reference information)</a></p>\n";
|
||||
$ret .= LJ::html_textarea({ 'name' => 'formatdata', 'value' => $style->{'formatdata'},
|
||||
'rows' => '30', 'cols' => '80', 'wrap' => 'off',
|
||||
'style' => 'width: 100%;' }) . "\n";
|
||||
}
|
||||
|
||||
# save button
|
||||
$ret .= "<p align='center'>" . LJ::html_submit(undef, 'Save Style') . "</p>\n";
|
||||
|
||||
$ret .= "</form></div>";
|
||||
|
||||
# convenience links at bottom
|
||||
if ($ide eq 'v2') {
|
||||
$ret .= "<?h1 Convenience Links h1?><?p You can use these links to scroll the page up to where the variable is declared... p?> <ul>";
|
||||
foreach my $v (sort { $a->{'name'} cmp $b->{'name'} } @vars) {
|
||||
next unless ($v->{'props'}->{'scope'} =~ /\b$style->{'type'}\b/);
|
||||
$ret .= "<li><a href=\"#$v->{'name'}\">$v->{'name'}</a>";
|
||||
}
|
||||
$ret .= "</ul>";
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# save changes from a previous edit form
|
||||
if ($mode eq "savechanges") {
|
||||
|
||||
my $formatdata;
|
||||
|
||||
# process form from ide v1
|
||||
if ($ide eq "v1") {
|
||||
$POST{'formatdata'} =~ s/\r//; # carriage returns shouldn't be necessary
|
||||
$formatdata = $POST{'formatdata'};
|
||||
|
||||
# process form from ide v2
|
||||
} elsif ($ide eq "v2") {
|
||||
$formatdata = "";
|
||||
foreach (grep { /^var:.+/ } keys %POST) {
|
||||
/^var:(.+)$/;
|
||||
my ($key, $var) = ($&, $1);
|
||||
$POST{$key} =~ s/\r//; # carriage returns shouldn't be necessary
|
||||
if ($POST{$key} =~ /\n/) {
|
||||
$formatdata .= "$var<=\n$POST{$key}\n<=$var\n\n";
|
||||
} else {
|
||||
$formatdata .= "$var=>$POST{$key}\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# update style
|
||||
LJ::S1::update_style($styleid,
|
||||
{ 'formatdata' => $formatdata,
|
||||
'styledes' => $POST{'styledes'},
|
||||
map { $_->{'code'} => $POST{$_->{'code'}} ? "Y" : "N" } @style_opts });
|
||||
|
||||
my $extravars;
|
||||
if ($style->{'type'} eq 'day') {
|
||||
my ($curmday, $curmon, $curyear) = (localtime(time))[3..5];
|
||||
$extravars = sprintf("&day=%02d&month=%02d&year=%04d",
|
||||
$curmday, $curmon+1, $curyear+1900);
|
||||
}
|
||||
# all good
|
||||
return "<?h1 Success h1?><?p Style has been updated. You can view it " .
|
||||
"<a target='preview' href=\"$LJ::SITEROOT/customview.cgi?user=$u->{'user'}" .
|
||||
"&styleid=$styleid$extravars\">here</a>. p?>";
|
||||
}
|
||||
|
||||
# this should never happen
|
||||
return LJ::bad_input("Unknown mode: $mode.");
|
||||
|
||||
}
|
||||
_code?>
|
||||
|
||||
<=body
|
||||
page?><?_c <LJDEP>
|
||||
link: htdocs/styles/edit.bml, htdocs/developer/views.bml, htdocs/customview.cgi
|
||||
file: htdocs/vars.dat
|
||||
post: htdocs/styles/edit_do.bml
|
||||
</LJDEP> _c?>
|
||||
26
livejournal/htdocs/styles/index.bml
Executable file
26
livejournal/htdocs/styles/index.bml
Executable file
@@ -0,0 +1,26 @@
|
||||
<?page
|
||||
title=><?_ml .title _ml?>
|
||||
body<=
|
||||
|
||||
<?_code
|
||||
return LJ::set_active_crumb('styles');
|
||||
_code?>
|
||||
|
||||
<?h1 <?_ml .about.header _ml?> h1?>
|
||||
<?_ml .about _ml?>
|
||||
<dl>
|
||||
<dt><a href="/modify.bml"><?_ml .nav.modify _ml?></a></dt>
|
||||
<dd><?_ml .nav.modify.about _ml?></dd>
|
||||
<dt><a href="create.bml"><?_ml .nav.create _ml?></a></dt>
|
||||
<dd><?_ml .nav.create.about _ml?></dd>
|
||||
<dt><a href="edit.bml"><?_ml .nav.edit _ml?></a></dt>
|
||||
<dd><?_ml .nav.edit.about _ml?></dd>
|
||||
<dt><a href="browse/"><?_ml .nav.browse _ml?></a></dt>
|
||||
<dd><?_ml .nav.browse.about _ml?></dd>
|
||||
</ul>
|
||||
<=body
|
||||
page?><?_c <LJDEP>
|
||||
link: htdocs/developer/embedding.bml, htdocs/developer/styles.bml
|
||||
link: htdocs/developer/index.bml, htdocs/paidaccounts/index.bml
|
||||
link: htdocs/modify.bml, htdocs/styles/create.bml, htdocs/styles/edit.bml
|
||||
</LJDEP> _c?>
|
||||
217
livejournal/htdocs/styles/tags.css
Executable file
217
livejournal/htdocs/styles/tags.css
Executable file
@@ -0,0 +1,217 @@
|
||||
fieldset
|
||||
{
|
||||
border: 1px solid #cdcdcd;
|
||||
padding: 0px 6px 6px 6px;
|
||||
}
|
||||
|
||||
legend
|
||||
{
|
||||
padding: 2px 10px 2px 10px;
|
||||
border: 1px solid #cdcdcd;
|
||||
font-weight: bold;
|
||||
/*
|
||||
font-family: Arial;
|
||||
background: #eee url(/img/grey_gradbg.gif);
|
||||
*/
|
||||
}
|
||||
|
||||
.tagsort
|
||||
{
|
||||
border-top: 1px solid #cdcdcd;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.taginfo
|
||||
{
|
||||
color: #777;
|
||||
padding: 4px;
|
||||
background: #eee url(/img/grey_gradbg.gif);
|
||||
border: 1px solid #cdcdcd;
|
||||
}
|
||||
|
||||
.tagbox
|
||||
{
|
||||
width: 300px;
|
||||
background-color: #eee;
|
||||
padding: 4px;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.tagbox option
|
||||
{
|
||||
background-position: center left;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 22px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.tagbox .level1
|
||||
{
|
||||
background-image: url(/img/level1.gif);
|
||||
}
|
||||
|
||||
.tagbox .level2
|
||||
{
|
||||
background-image: url(/img/level2.gif);
|
||||
}
|
||||
|
||||
.tagbox .level3
|
||||
{
|
||||
background-image: url(/img/level3.gif);
|
||||
}
|
||||
|
||||
.tagbox .level4
|
||||
{
|
||||
background-image: url(/img/level4.gif);
|
||||
}
|
||||
|
||||
.tagbox .level5
|
||||
{
|
||||
background-image: url(/img/level5.gif);
|
||||
}
|
||||
|
||||
.tagfield
|
||||
{
|
||||
border: 1px solid #cdcdcd;
|
||||
}
|
||||
|
||||
.tagfield_error
|
||||
{
|
||||
border: 1px solid red;
|
||||
background-color: #ecd7d7;
|
||||
}
|
||||
|
||||
.tagfield:focus
|
||||
{
|
||||
background-color: #eee;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.btn
|
||||
{
|
||||
border-left: 1px solid #999;
|
||||
border-top: 1px solid #999;
|
||||
border-right: 1px solid #555;
|
||||
border-bottom: 1px solid #555;
|
||||
}
|
||||
|
||||
.btn:hover
|
||||
{
|
||||
background-color: #eee;
|
||||
border-right: 1px solid #999;
|
||||
border-bottom: 1px solid #999;
|
||||
border-left: 1px solid #555;
|
||||
border-top: 1px solid #555;
|
||||
}
|
||||
|
||||
#selected_tags
|
||||
{
|
||||
padding: 5px;
|
||||
margin-bottom: 10px;
|
||||
color: #777;
|
||||
width: 300px;
|
||||
white-space: wrap;
|
||||
}
|
||||
|
||||
.proptbl
|
||||
{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.proptbl td
|
||||
{
|
||||
padding: 4px;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
/* table headers */
|
||||
.proptbl .h
|
||||
{
|
||||
color: #777;
|
||||
padding: 4px;
|
||||
background: #eee url(/img/grey_gradbg.gif);
|
||||
border: 1px solid #cdcdcd;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* counts */
|
||||
.proptbl .c
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* count type */
|
||||
.proptbl .t
|
||||
{
|
||||
color: #777;
|
||||
text-align: right;
|
||||
background-color: #fbfbfb;
|
||||
border-right: 1px solid #cdcdcd;
|
||||
}
|
||||
|
||||
/* results */
|
||||
.proptbl .r
|
||||
{
|
||||
color: #777;
|
||||
text-align: right;
|
||||
background-color: #fbfbfb;
|
||||
font-weight: bold;
|
||||
border-right: 1px solid #cdcdcd;
|
||||
}
|
||||
|
||||
/* result value */
|
||||
.proptbl .rv
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #eee;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* edittags.bml */
|
||||
.edittbl td
|
||||
{
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
/* labels */
|
||||
.edittbl .l, .lsep
|
||||
{
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
white-space: nowrap;
|
||||
border-right: 1px solid #777;
|
||||
}
|
||||
|
||||
/* separator line */
|
||||
.edittbl .sep
|
||||
{
|
||||
border-top: 1px solid #777;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.curtags
|
||||
{
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.tagbox_nohist
|
||||
{
|
||||
width: 300px;
|
||||
background-color: #eee;
|
||||
padding: 4px;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.tagbox_nohist option
|
||||
{
|
||||
background-position: center left;
|
||||
background-repeat: no-repeat;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.update_good
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user