# Support Wikipedia anchors in onebox

**URL:** <https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664>\
**Category:** Feature\
**Created:** [2014年九月5日 05:43 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664 "2014-09-05T05:43:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2014年九月5日 05:43 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/1 "2014-09-05T05:43:23Z")

</div>

It would be nice if [HTTP cookie - Wikipedia](http://en.wikipedia.org/wiki/HTTP_cookie#Secure_cookie) oneboxed the correct section, instead of the top section.

> **[HTTP cookie | Secure cookie](https://en.wikipedia.org/wiki/HTTP_cookie#Secure_cookie)**
>
> A secure cookie can only be transmitted over an encrypted connection (i.e. HTTPS). They cannot be transmitted over unencrypted connections (i.e. HTTP). This makes the cookie less likely to be exposed to cookie theft via eavesdropping. A cookie is made secure by adding the Secure flag to the cookie.
> An http-only cookie cannot be accessed by client-side APIs, such as JavaScript. This restriction eliminates the threat of cookie theft via cross-site scripting (XSS). However, the cookie remains vulne...

---

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [2014年九月5日 10:20 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/2 "2014-09-05T10:20:37Z")

</div>

for fun and giggles  
**[jsFiddle Experiment | Getting wikipedia section content with ajax](http://jsfiddle.net/lid0/m320cwuz/3/embedded/result/)**

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/lid0/m320cwuz/)**
>
> JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.

utilizing the Wikipedia API ( [API:Action API - MediaWiki](http://www.mediawiki.org/wiki/API:Main_page) ).

To retrieve the section content with this approach I had to make 2 requests

1. get a list of all the sections of an article to identify its numeric id (needed for the 2nd request)
2. request of a particular section content based on the id.

The bad  
The solution return the entire section and not just the first paragraphs as onebox appears to do.  
I was thinking that using the wiki api might make the process more efficient at least, but it is not  
additional processing is required to fix relative a tags

- it also return some nonsense [edit] text

my conclusion is that is probably better to just go with the current approach and use Nokogiri for section parsing 😄

---

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [2014年九月8日 08:00 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/3 "2014-09-08T08:00:52Z")

</div>

[https://github.com/lidlanca/onebox/commit/3ccb2d7fccbb1eab4108307fc4c20baa7c46a554](https://github.com/lidlanca/onebox/commit/3ccb2d7fccbb1eab4108307fc4c20baa7c46a554)

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2014年九月8日 08:05 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/4 "2014-09-08T08:05:04Z")

</div>

WAT awesome you got your dev environment going!

---

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [2014年九月8日 08:16 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/5 "2014-09-08T08:16:41Z")

</div>

Technically my Dev environment is working but it is limping due to virtualbox issues.  
Hopefully the next virtualbox release will magically fix the bug I experience.

But luckily the onebox can be worked as a standalone, wasn’t too much trouble to get it working on windows.

---

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [2014年九月10日 04:42 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/6 "2014-09-10T04:42:29Z")

</div>

This is working now 😄

```
http://en.wikipedia.org/wiki/HTTP_cookie
```

> **[HTTP cookie](https://en.wikipedia.org/wiki/HTTP_cookie)**
>
> An HTTP cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie) is a small block of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user's web browser. Cookies are placed on the device used to access a website, and more than one cookie may be placed on a user's device during a session.
> Cookies serve useful and sometimes essential functions on the web. They enable web servers to store stateful ...

```
http://en.wikipedia.org/wiki/HTTP_cookie#Secure_cookie
```

> **[HTTP cookie | Secure cookie](https://en.wikipedia.org/wiki/HTTP_cookie#Secure_cookie)**
>
> A secure cookie can only be transmitted over an encrypted connection (i.e. HTTPS). They cannot be transmitted over unencrypted connections (i.e. HTTP). This makes the cookie less likely to be exposed to cookie theft via eavesdropping. A cookie is made secure by adding the Secure flag to the cookie.
> An http-only cookie cannot be accessed by client-side APIs, such as JavaScript. This restriction eliminates the threat of cookie theft via cross-site scripting (XSS). However, the cookie remains vulne...

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2014年九月10日 04:43 UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/7 "2014-09-10T04:43:20Z")

</div>


