From 6113586b830cb3c8233d89d1fb2b98b03baf7287 Mon Sep 17 00:00:00 2001 From: Bertrand Le Roy Date: Mon, 7 Nov 2011 16:01:31 -0800 Subject: [PATCH] Bing search --- Search.cshtml | 36 ++++++++++++++++++++++++++++++++++++ Styles/Site.css | 8 ++++++++ Web.config | 4 ++++ _SiteLayout.cshtml | 4 +++- 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Search.cshtml diff --git a/Search.cshtml b/Search.cshtml new file mode 100644 index 00000000..818a5896 --- /dev/null +++ b/Search.cshtml @@ -0,0 +1,36 @@ +@using System.Configuration +@using System.Xml.Linq +@{ + const int pageSize = 10; + XNamespace web = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/web"; + var appid = ConfigurationManager.AppSettings["bingAppId"]; + var pageNumber = int.Parse(Request.QueryString["p"] ?? "0"); + var q = Request.QueryString["q"] ?? ""; + Page.Title = "Orchard Documentation - Search - " + q; + var requestString = "http://api.bing.net/xml.aspx?" + + "AppId=" + appid + + "&Query=" + Html.Encode(q) + "%20site:docs.orchardproject.net" + + "&Sources=Web" + + "&Version=2.0" + + "&Market=en-us" + + "&Adult=Moderate" + + "&Options=EnableHighlighting" + + "&Web.Count=" + pageSize + + "&Web.Offset=" + (pageNumber * pageSize) + + "&Web.Options=DisableHostCollapsing+DisableQueryAlterations"; + var request = (HttpWebRequest)WebRequest.Create(requestString); + var response = request.GetResponse().GetResponseStream(); + var results = XElement.Load(response); +} + \ No newline at end of file diff --git a/Styles/Site.css b/Styles/Site.css index 2656fbe9..82994793 100644 --- a/Styles/Site.css +++ b/Styles/Site.css @@ -1081,6 +1081,14 @@ img.thumb { min-height: 80px; } +#SearchResultsDiv header { + font-size: 0.8em; +} + +#SearchResultsDiv li { + list-style: none; +} + /* Search page end */ #siteInfo { diff --git a/Web.config b/Web.config index 2b5b2ed8..292fac2c 100644 --- a/Web.config +++ b/Web.config @@ -1,7 +1,11 @@  + + + + diff --git a/_SiteLayout.cshtml b/_SiteLayout.cshtml index c9241ca4..a6b3bd11 100644 --- a/_SiteLayout.cshtml +++ b/_SiteLayout.cshtml @@ -40,7 +40,9 @@
- »
+
+ »
+