Tuesday, December 09, 2008

vimrc

완전 간단한 개인용 세팅
예전엔 뭔가 많았는데 점점 심플해 지는 듯... 애정이 식는 건지

set nu
set si
syntax on
set tabstop=4
set sw=4
set expandtab
set ruler
set fenc=utf-8
set fencs=utf-8,cp949

Wednesday, November 12, 2008

파이어폭스 검색엔진에 네이버 사전 추가하기

파이어폭스를 사용하면서 alt+k 단축키를 사랑하는 편이다. 그리고 검색은 주로 네이버와 구글을 번갈아 가면서.. 이때도 알트키와 방향키를 사용하므로 마우스를 쓸 필요가 크게 없어서 편리하다.

다만, 모르는 영단어를 찾을 때는 좀 alt+l로 dic.naver.com을 가서 찾는 등 좀 번거로운 것이 문제라면 문제.

검색 창에 네이버 사전을 집어 넣기로 했다. 유튜브라던지 하는 곳에 가면 검색창에 추가하는 메뉴가 생겨서 편리하지만, 네이버 사전에서는 이것이 지원안되므로 패스. 파이어폭스 검색엔진 추가 메뉴에도 "사전"은 없으므로(영/영사전 제외) 패스. 결국 손으로 만들어 넣어야 할 것 같아 보였다.

searchplugins 라는 디렉토리가 파폭 디렉토리 밑에 존재한다는 첩보를 입수...( 즉, C:\Program Files\Mozilla Firefox\searchplugins )

xml 파일들이 보였다. 빙고!

이중 naver-kr.xml을 카피해서 naver-dict-kr.xml을 만들고 내용을 수정하기로 했다.
naver-kr.xml의 내용은 다음과 같았다.

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>네이버</ShortName>
<Description>네이버 검색</Description>
<Image width="16" height="16">data:image/gif;base64,R0l(생략)...</Image>

<Url type="application/x-suggestions+json" method="GET" template="http://ac.search.naver.com/autocompl">
<Param name="m" value="s" />
<Param name="ie" value="utf-8" />
<Param name="q" value="{searchTerms}" />
</Url>

<Url type="text/html" method="GET" template="http://search.naver.com/search.naver">
<Param name="where" value="nexearch"/>
<Param name="frm" value="ff"/>
<Param name="sm" value="oss"/>
<Param name="ie" value="utf8"/>
<Param name="query" value="{searchTerms}"/>
</Url>
<SearchForm>http://search.naver.com</SearchForm>
</SearchPlugin>


ShortName은 이름일 거고, Description은 설명일거고, Image는 아이콘인지 파비콘인지 할거고...
첫번째 Url 태그는 자동완성을 위한 주소겠네... 아.. 자동완성이 이렇게 되는 구나...
두번째 Url 태그가 실제 검색 주소라고 생각하고 나니 내용은 다 파악되었다.

그래서 이름과 설명을 "네이버 사전"이라고 바꾸고, 이미지는 냅두고, 자동완성도 네이버에서 자동완성하도록 냅두었다.

결국 두번째 Url만 중요한 셈인데, 한 단어를 실제 네이버 사전(http://dic.naver.com)에서 찾아보고 주소를 (http://dic.naver.com/search.nhn) 알아내었다.

그래서 두번째 Url의 template를 http://dic.naver.com/search.nhn로 바꾸고, SearchForm을 http://dic.naver.com/로 변경. 그리고 파폭 재시작 후 확인하였더니 매우 잘 작동했다.

잠시동안 사용하다보니, 네이버랑 네이버 사전이랑 걍 아이콘이 똑같아서 헷갈리더라. 그래서 네이버 사전 안에 있는 아무 아이콘이나 가져다가 쓸려고 이걸 골랐다.



그런데 Image tag를 직접 보면 알겠지만, 이미지 주소가 있어서 그걸 파폭이 매번 다운해 오는 게 아니라, 이미지를 걍 데이터 스트링으로 바꾼 것 같다.

한참 인터넷을 뒤지다 보니, 이런 페이지이런 링크를 구할 수 있었다.
두번째 링크에서 이미지를 변환시켜서 얻은 스트링을 본문에 대입하고 파폭 재시작.

대만족 ^^

HOWTO add search engine to firefox

Problem : I just wanted to add a search engine to FF 3 which is not supported by FF search engine add-ons.

Sol: Because the search engine itself did not support FF search engine add-on either, I had to add it by hand.

Someone suggested editing the about:config page, but it will change the default search engine, it didn't help.

After googling, I found that searchplugins directory exists under your directory( e.g. Mozilla FirefoxC:\Program Files\Mozilla Firefox\searchplugins ). There were several xml files. So I opened some of them with text editor. Not knowing what to do exactly, I copied one of them and renamed as I wished. For example "yahoo-kr.xml" It looked like ....

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>Yahoo</ShortName>
<Description>Yahoo Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,R0l...</Image>
<Url type="application/x-suggestions+json" method="GET"
template="http://kr.ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}" />
<Url type="text/html" method="GET" template="http://kr.search.yahoo.com/search">
<Param name="p" value="{searchTerms}"/>
<Param name="ei" value="UTF-8"/>
<MozParam name="fr" condition="pref" pref="yahoo-fr-cjkt" />
</Url>
<SearchForm>http://kr.search.yahoo.com/</SearchForm>
</SearchPlugin>



So, I guessed that ShortName would be its name, description the description. Image will be the icon or favicon, and the first Url tag will be the url for autocompletion. The last url tag will be the search engine url.

Rename the ShortName and description as I wished, I could have give up the auto completion, but I just used the old one.

The second URL tag and SearchForm tag are changed as I wanted. then, it just worked.

I was satisfied for a few seconds, then I found that two different search engine had the same favicon and that was so confusing.

So I googled again, and found this page and that page had this link. So I could obtain the character string from an image. By putting this string in the Image Tag. I finally could pleased.