paint-brush
브라우저 북마크를 통한 참고문헌 생성기: 작동 방식by@bobnoxious
1,245
1,245

브라우저 북마크를 통한 참고문헌 생성기: 작동 방식

Bob Wright5m2023/11/27
Read on Terminal Reader

간단한 참고문헌 생성기는 브라우저 북마크 파일을 소스 콘텐츠로 사용합니다. 데이터베이스 자체는 실제로 로컬에 저장하고 사용할 수 있는 JSON 개체 파일입니다. 예를 들어 브라우저가 내 북마크 데이터를 저장하지 않고도 Chrome, Edge 및 Firefox에서 동일한 북마크 세트를 얻을 수 있습니다. 사용하려는 북마크만 추출하기 위해 북마크 폴더를 편집합니다.
featured image - 브라우저 북마크를 통한 참고문헌 생성기: 작동 방식
Bob Wright HackerNoon profile picture
0-item

JSON 브라우저 북마크 파일을 소스 콘텐츠로 사용하는 간단한 참고문헌 생성기입니다.

전제 조건 및 코드

참고문헌 생성기 작동을 위한 첫 번째 요구 사항은 xbrowserSync 라는 브라우저 북마크 관리자 애플리케이션에서 생성된 JSON 개체로 구성된 콘텐츠 데이터의 소스입니다. 이 애플리케이션은 두 부분으로 구성된 브라우저에 구애받지 않는 북마크 관리자입니다.


한 부분은 브라우저 확장이고, 다른 부분은 북마크 데이터를 MongoDB 데이터 파일로 관리하는 서버 API입니다. 서버 API에 대해 알아야 할 것은 URL뿐입니다. 브라우저 확장 프로그램은 Chrome 브라우저용 Google Play 와 같은 온라인 앱 '스토어'에서 찾을 수 있습니다.


기본 아이디어는 xbrowserSync 응용 프로그램이 API 서버에 저장된 암호화된 데이터베이스에 북마크 데이터를 저장한다는 것입니다. 데이터베이스 자체는 실제로 로컬에 저장하고 사용할 수 있는 JSON 개체 파일이며, 애플리케이션 확장이 적절하게 설치된 모든 브라우저에서 사용할 수 있습니다.


예를 들어 브라우저가 내 북마크 데이터를 저장하지 않고도 Chrome, Edge 및 Firefox에서 동일한 북마크 세트를 얻을 수 있습니다. xbrowserSync 용 APP 및 API 소스는 각각 GitHub 저장소에 있습니다.


참고문헌 생성기의 두 번째 요구 사항은 Windows 10 컴퓨터의 명령 창 에 있는 node.js 에서 실행되는 프로그램 코드입니다. 다음은 handler.js 라는 간단한 노드 프로그램입니다.

 #!/usr/bin/env node // --------------------------------- // Simple bibliography file handler Node Server API // --------------------------------- const fs = require('fs') const path = require('path') //const dn = require('./dirname'); var filePath = './bibliotest.json'; //the biblio bookmark file var biblio = ''; var str = ''; var searchValue = 'url:'; // -------------- // read and parse biblio JSON file // ---------------- const jsonReader = () => { return new Promise(resolve => { str = fs.readFile(filePath, (err, fd) => { object = JSON.parse(fd); str = object.children; // strip outer layer biblio = str; // count biblio array elements count = biblio.length; resolve (str); //return str; }) }) } // async function performAsyncFunctions(){ // list of promises to execute sequentially const firstRequest = await jsonReader(); //console.log('\nAll tasks complete.'); console.log('==== function complete ====\n') console.log('count = ', count) var html = '<html><lang = en><head></head><body>'; for (let i = 0; i < count; i++) { html = html + '<h3><i>id'+[i]+':</i>&nbsp;<a href='+biblio[i].url+'>'+biblio[i].title+'</a></h3><p>'+biblio[i].description+'</p>\n'; } html = html + '</body></html>'; console.info(html); const content = html try { const data = fs.writeFileSync('./bibliotest.html', content) //file written successfully } catch (err) { console.error(err) }} // --------------- performAsyncFunctions(); // console.log('biblio = ', object) // ------------------


JSON 형식 북마크 파일

xbrowserSync 브라우저 확장 메뉴에서 북마크 데이터의 백업을 저장하도록 선택할 수 있습니다. 백업은 JSON 파일로 저장됩니다. 여기 예에서는 모든 북마크가 "MuskArticle"이라는 북마크 폴더에 있습니다.


참고문헌에 사용하려는 북마크 폴더만 추출하기 위해 북마크 JSON을 편집합니다. 이 JSON 파일은 아래에 표시됩니다.

 { "title": "__MuskArticle", "children": [ { "title": "Musk's X caught throttling outbound links to websites he doesn't like", "url": "https://www.msn.com/en-us/news/technology/musk-sx-caught-throttling-outbound-links-to-websites-he-doesn-t-like/ar-AA1fmbYw?ocid=windirect&cvid=3ff1100b6fba4172b3b0b8b9c6bbc7e0&ei=185", "description": "Elon Musk claims that he bought Twitter, now called X, to preserve free speech. He claimed that everyone's voice should be heard. This is a great thing for free speech and must surely be a coincidence, right? Elon Musk's X was this week caught throttling outbound links to several sites, coincidentally ones that the billionaire has complained about or feuded with in the past.… Links directing users of the website formerly…", "id": 6643 }, { "title": "Mark Cuban takes another jab at Elon Musk's business practices", "url": "https://www.msn.com/en-us/money/companies/mark-cuban-takes-another-jab-at-elon-musk-s-business-practices/ar-AA1fmrNQ?ocid=windirect&cvid=528ef4be846842fa87342b96d92d0dfa&ei=35", "description": "These two billionaires are not best buds.", "id": 6664 }, { "title": "Twitter now makes you PAY to access one of its most popular features", "url": "https://www.msn.com/en-us/money/technology/twitter-now-makes-you-pay-to-access-one-of-its-most-popular-features/ar-AA1flk5Y?ocid=windirect&cvid=ee4ba03e4c414849a910c7f25dbfd759&ei=27", "description": "X (formerly Twitter) has started diverting users to a paid-subscription sign-up page when they try to access TweetDeck.", "id": 6665 }, { "title": "NYU Professor Locked Out of Twitter After Reportedly Declining to Meet With Elon Musk", "url": "https://www.msn.com/en-us/news/technology/nyu-professor-locked-out-of-twitter-after-reportedly-declining-to-meet-with-elon-musk/ar-AA1fmedB?ocid=windirect&cvid=a7973a74a0d24f2287ea421bbd70f5ea&ei=42", "description": "New York University professor and Kara Swisher's podcasting buddy Scott Galloway voiced his outrage at being banned from posting on Twitter in a Threads post on Tuesday. Galloway claims he's been locked out of Twitter (aka X) two days after allegedly declining an invitation to meet with the chief…", "id": 6666 }, { "title": "A federal judge wondered if Elon Musk was trying to 'cozy up' to Trump by trying to inform him about a search warrant into his social media account", "url": "https://www.msn.com/en-us/news/politics/a-federal-judge-wondered-if-elon-musk-was-trying-to-cozy-up-to-trump-by-trying-to-inform-him-about-a-search-warrant-into-his-social-media-account/ar-AA1flSZV?ocid=windirect&cvid=ee4ba03e4c414849a910c7f25dbfd759&ei=51", "description": "In January, federal prosecutors obtained a search warrant to obtain information from Trump's personal Twitter account.", "id": 6667 } ] }


참고문헌 파일

위의 JSON 파일을 node.js 핸들러 프로그램에 제출하면 다음과 같은 HTML 형식 참고문헌 목록이 생성됩니다.


결론

따라서 우리는 xbrowserSync를 북마크 관리자로 활용하여 북마크 데이터에서 참고문헌을 생성하는 방법을 살펴보았습니다. 읽어주셔서 감사합니다. 이 정보가 귀하에게 도움이 되기를 바랍니다. 언제나처럼 의견, 제안, 비판을 환영합니다.