Add a search module to layouts, if the journal is searchable.
Patch by foxfirefey.
diffs (389 lines):
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/bases/layout.s2
--- a/bin/upgrading/s2layers/bases/layout.s2 Wed Jun 02 18:48:11 2010 +0800
+++ b/bin/upgrading/s2layers/bases/layout.s2 Wed Jun 02 20:20:51 2010 +0800
@@ -119,6 +119,7 @@ propgroup modules {
property use module_time_group;
property use module_poweredby_group;
property use module_credit_group;
+ property use module_search_group;
}
##===============================
@@ -502,6 +503,11 @@ background: $*color_module_link_hover; }
.module-credit .module-content {padding: 0 0.5em 0 0.5em; }
+/* -------- search -------- */
+
+.search-form { margin: .2em auto; }
+.search-box { margin: .2em; }
+
/* ====================== NAVIGATION BAR ======================= */
.navigation ul {margin: 0; padding: 0; list-style: none; border-top: 0.083em
solid $*color_page_border; }
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/basicboxes/layout.s2
--- a/bin/upgrading/s2layers/basicboxes/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/basicboxes/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -265,6 +265,12 @@ text-align: center; }
.module-navlinks ul li a { font-size: small;
padding: .15em .5em; }
+.module-search input { border: 1px solid $*color_entry_border;
+ background: $*color_entry_background, !important;
+ font-size: .9em !important;
+ color: $*color_entry_text !important; }
+.module-search .search-form { text-align: right; }
+
""";
}
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/blanket/layout.s2
--- a/bin/upgrading/s2layers/blanket/layout.s2 Wed Jun 02 18:48:11 2010 +0800
+++ b/bin/upgrading/s2layers/blanket/layout.s2 Wed Jun 02 20:20:51 2010 +0800
@@ -101,6 +101,7 @@ propgroup modules {
property use module_time_group;
property use module_poweredby_group;
property use module_credit_group;
+ property use module_search_group;
property string module_navlinks_section_override {
values = "none|(none)|two|Fixed";
@@ -316,6 +317,9 @@ ul.userlite-interaction-links li { displ
.module-credit dt, .module-credit dd { display: inline; margin: 0; padding: 0;
}
.module-credit dt { font-weight: bold; margin-right: 0.5em; }
+.module-search .search-form { margin: .2em auto; }
+.module-search .search-box { margin: .2em; }
+
/*--- entry ---*/
div.entry { padding: 2em; margin: 0 0 2em 0; border-left: 20px solid
$*color_page_border; $entry_colors }
div.entry-content { margin: 1em 0 0 0; }
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/brittle/layout.s2
--- a/bin/upgrading/s2layers/brittle/layout.s2 Wed Jun 02 18:48:11 2010 +0800
+++ b/bin/upgrading/s2layers/brittle/layout.s2 Wed Jun 02 20:20:51 2010 +0800
@@ -188,6 +188,7 @@ propgroup modules {
property use module_time_group;
property use module_poweredby_group;
property use module_credit_group;
+ property use module_search_group;
}
# explicitly define what sections the layout has available
@@ -795,6 +796,9 @@ ul.userlite-interaction-links li {
padding-top: 1em;
}
+.module-search .search-form { margin: .2em auto; }
+.module-search .search-box { margin: .2em; }
+
#tertiary .module-content ul {
list-style-image: none;
list-style-position: outside;
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2 Wed Jun 02 18:48:11 2010 +0800
+++ b/bin/upgrading/s2layers/core2.s2 Wed Jun 02 20:20:51 2010 +0800
@@ -910,6 +910,9 @@ function builtin viewer_is_member() : bo
function builtin viewer_is_member() : bool
"Returns true if the user viewing the page is both logged in, and is a member
of the community being viewed. Always returns false for personal journals,
since they cannot have members.";
+function builtin viewer_can_search() : bool
+"Returns true if the user viewing the page is logged in and can search that
journal.";
+
function builtin viewer_sees_control_strip [fixed] : bool
"Returns true if reader will see the built in control strip.";
@@ -980,6 +983,9 @@ function builtin htmlattr(string name, s
function builtin htmlattr(string name, int value) : string
"If the value isn't blank, return in HTML attribute format with a leading
space. HTML of name is not escaped.";
+
+function builtin print_search_form(string button_text)
+"Prints a search form, with the button text as the label to the submit
button.";
##[ properties ]
@@ -1487,6 +1493,19 @@ property string{}[] layout_resources { n
set layout_authors = [];
set layout_resources = [];
+
+property string[] module_search_group {
+ des = "Search";
+ grouptype = "module";
+}
+set module_search_group = ["module_search_show", "module_search_order",
"module_search_section"];
+property bool module_search_show { grouped = 1; }
+property int module_search_order { grouped = 1; }
+property string module_search_section { grouped = 1; }
+
+set module_search_show = true;
+set module_search_order = 15;
+set module_search_section = "one";
##===============================
## Journal style - fonts
@@ -2708,7 +2727,8 @@ function modules_init()
if ( $*module_time_show ) {
$*module_sections{$*module_time_section}[$*module_time_order]=["time"]; }
if ( $*module_poweredby_show ) {
$*module_sections{$*module_poweredby_section}[$*module_poweredby_order]=["poweredby"];
}
if ( $*module_customtext_show ) {
$*module_sections{$*module_customtext_section}[$*module_customtext_order]=["customtext"];
}
- if ( $*module_credit_show ) { $*module_sections{$*module_credit_section
}[$*module_credit_order]=["credit"]; }
+ if ( $*module_credit_show ) {
$*module_sections{$*module_credit_section}[$*module_credit_order]=["credit"]; }
+ if ( $*module_search_show ) {
$*module_sections{$*module_search_section}[$*module_search_order]=["search"]; }
#if ( $*module_%%mod%%_show ) { $*module_sections{$*module_%%mod%%_section
}[$*module_%%mod%%_order]=["%%mod%%"]; }
}
@@ -3576,6 +3596,18 @@ function print_module_list(string[] list
}
}
+function print_module_search() {
+ # only print this module if the viewer can search this journal
+ if (viewer_can_search()) {
+ var Page p = get_page();
+ var string title = "Search";
+
+ open_module("search", $title, "$*SITEROOT/search?user=" +
$p.journal.username);
+ print_search_form("Search");
+ close_module();
+ }
+}
+
function print_module_userprofile() {
var Page p = get_page();
var string title = "Profile";
@@ -3983,6 +4015,9 @@ function handle_module_group_array(strin
}
elseif ($module == "credit") {
print_module_credit();
+ }
+ elseif ($module == "search") {
+ print_module_search();
}
}
}
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/core2base/layout.s2
--- a/bin/upgrading/s2layers/core2base/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/core2base/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -193,6 +193,7 @@ propgroup modules {
property use module_time_group;
property use module_poweredby_group;
property use module_credit_group;
+ property use module_search_group;
}
# explicitly define what sections the layout has available
@@ -678,6 +679,11 @@ ul.userlite-interaction-links li {
display: block;
padding: 2px;
}
+
+.search-box {
+ margin: .2em auto;
+}
+
/* wrap long content, particularly openid usernames */
.module-pagesummary .ljuser {
white-space: normal !important;
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/drifting/layout.s2
--- a/bin/upgrading/s2layers/drifting/layout.s2 Wed Jun 02 18:48:11 2010 +0800
+++ b/bin/upgrading/s2layers/drifting/layout.s2 Wed Jun 02 20:20:51 2010 +0800
@@ -209,6 +209,7 @@ propgroup modules
property use module_userprofile_group;
property use module_time_group;
property use module_credit_group;
+ property use module_search_group;
}
set module_layout_sections = "none|(none)|one|Sidebar|two|Footer";
@@ -304,6 +305,7 @@ function Page::print_default_stylesheet(
clear: left;
width: 224px;
height: 1.5em;
+ margin-top: .5em;
$module_footer_colors
}
@@ -358,7 +360,6 @@ function Page::print_default_stylesheet(
.module-content {
$module_font
}
-
/* Header
***************************************************************************/
diff -r e1f39e724a18 -r 529764d8e9d7
bin/upgrading/s2layers/fluidmeasure/layout.s2
--- a/bin/upgrading/s2layers/fluidmeasure/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/fluidmeasure/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -536,6 +536,16 @@ border-color: transparent !important;
.module-time,
.module-powered { padding: .5em; }
+.module-search .search-box, .module-search .search-button {
+ -moz-border-radius: 1em;
+ -webkit-border-radius: 1em;
+ -khtml-border-radius: 1em;
+ background-color: $*color_entry_background;
+ border: 1px solid $*color_module_title_background;
+}
+.module-search .search-form { margin: .2em auto; }
+.module-search .search-box { margin: .2em; width: 95%; }
+.module-search .search-form { text-align: right; }
/* footer */
diff -r e1f39e724a18 -r 529764d8e9d7
bin/upgrading/s2layers/funkycircles/layout.s2
--- a/bin/upgrading/s2layers/funkycircles/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/funkycircles/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -956,6 +956,35 @@ h2#pagetitle {
$module_title_colors
}
+.module-search .search-form {
+ margin: 0 auto;
+ text-align: center;
+ }
+
+.module-search .search-box {
+ background-color: $*color_entry_border;
+ border: 0;
+ color: $*color_entry_background;
+ padding: .3em;
+ width: 90%;
+ -moz-border-radius: .2em;
+ -webkit-border-radius: .2em;
+ -moz-box-shadow: .067em .067em .134em #8c8c8c;
+ -webkit-box-shadow: .067em .067em .134em #8c8c8c;
+ }
+
+.module-search .search-button {
+ background-color: $*color_page_title_background;
+ border: 0;
+ color: $*color_entry_footer_link;
+ margin-top: .3em;
+ padding: .3em;
+ -moz-border-radius: .2em;
+ -webkit-border-radius: .2em;
+ -moz-box-shadow: .067em .067em .134em #111;
+ -webkit-box-shadow: .067em .067em .134em #111;
+ }
+
/* Footer
***************************************************************************/
diff -r e1f39e724a18 -r 529764d8e9d7
bin/upgrading/s2layers/funkycircles/themes.s2
--- a/bin/upgrading/s2layers/funkycircles/themes.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/funkycircles/themes.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -79,11 +79,13 @@ function Page::print_theme_stylesheet()
"""
/* Modules
***************************************************************************/
- .module-calendar td.empty-day {
+ .module-calendar td.empty-day,
+ .module-search .search-button {
background-color: $*color_header_background;
}
- .module-calendar td.entry-day a {
+ .module-calendar td.entry-day a,
+ .module-search .search-box {
color: $*color_page_subtitle !important;
}
@@ -410,7 +412,8 @@ function Page::print_theme_stylesheet()
"""
/* Modules
***************************************************************************/
- .module-calendar td.entry-day a {
+ .module-calendar td.entry-day a,
+ .module-search .search-box {
color: $*color_entry_text !important;
}
@@ -507,7 +510,8 @@ function Page::print_theme_stylesheet()
"""
/* Modules
***************************************************************************/
- .module-calendar td.entry-day {
+ .module-calendar td.entry-day,
+ .module-search .search-box {
background-color: $*color_page_link_hover;
-moz-box-shadow: .067em .067em .134em #444;
-webkit-box-shadow: .067em .067em .134em #444;
@@ -607,7 +611,8 @@ function Page::print_theme_stylesheet()
"""
/* Modules
***************************************************************************/
- .module-calendar td.entry-day {
+ .module-calendar td.entry-day,
+ .module-search .search-box {
background-color: $*color_page_link_hover;
-moz-box-shadow: .067em .067em .134em #444;
-webkit-box-shadow: .067em .067em .134em #444;
diff -r e1f39e724a18 -r 529764d8e9d7 bin/upgrading/s2layers/negatives/layout.s2
--- a/bin/upgrading/s2layers/negatives/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/negatives/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -179,6 +179,7 @@ propgroup modules {
property use module_time_group;
property use module_poweredby_group;
property use module_credit_group;
+ property use module_search_group;
}
diff -r e1f39e724a18 -r 529764d8e9d7
bin/upgrading/s2layers/skittlishdreams/layout.s2
--- a/bin/upgrading/s2layers/skittlishdreams/layout.s2 Wed Jun 02 18:48:11
2010 +0800
+++ b/bin/upgrading/s2layers/skittlishdreams/layout.s2 Wed Jun 02 20:20:51
2010 +0800
@@ -193,6 +193,7 @@ propgroup modules {
property use module_poweredby_group;
property use module_customtext_group;
property use module_credit_group;
+ property use module_search_group;
property string module_navlinks_section_override {
values = "none|(none)|one|Header|two|Sidebar";
@@ -219,6 +220,7 @@ set module_calendar_section = "two";
set module_calendar_section = "two";
set module_customtext_section = "two";
set module_credit_section = "two";
+set module_search_section = "two";
set grouped_property_override = { "module_navlinks_section" =>
"module_navlinks_section_override",
"module_poweredby_section" =>
"module_poweredby_section_override",
diff -r e1f39e724a18 -r 529764d8e9d7 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm Wed Jun 02 18:48:11 2010 +0800
+++ b/cgi-bin/LJ/S2.pm Wed Jun 02 20:20:51 2010 +0800
@@ -2616,6 +2616,34 @@ sub viewer_sees_control_strip
return LJ::Hooks::run_hook( 'show_control_strip' );
}
+# Returns true if the viewer can search this person's journal
+sub viewer_can_search {
+ my $remote = LJ::get_remote();
+ return 0 unless $remote;
+ return 0 unless defined $LJ::S2::CURR_PAGE;
+
+ my $ju = $LJ::S2::CURR_PAGE->{_u};
+
+ # return based on this function
+ return $ju->allow_search_by( $remote );
+}
+
+# Returns a search form for this journal
+sub print_search_form {
+ return "" unless defined($LJ::S2::CURR_PAGE);
+
+ my $ju = $LJ::S2::CURR_PAGE->{_u};
+
+ my $search_form = '<div class="search-form">';
+ $search_form .= '<form method="post" action="'. $LJ::SITEROOT.
'/search?user=' . $ju->user . '">';
+ $search_form .= LJ::form_auth();
+ $search_form .= '<input class="search-box" type="text" name="query"
maxlength="255">';
+ $search_form .= '<input class="search-button" type="submit" value="' .
$_[1] . '" />';
+ $search_form .= '</form></div>';
+
+ S2::pout( $search_form );
+}
+
# maintained only for compatibility with core1, eventually these can be removed
# when we've upgraded everybody. or we keep this cruft until the cows come
home
# as a stolid reminder to our past.
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog