Cov txheej txheem:

Lub Digital Sign Server ntawm Raspberry Pi: 8 Kauj Ruam
Lub Digital Sign Server ntawm Raspberry Pi: 8 Kauj Ruam

Video: Lub Digital Sign Server ntawm Raspberry Pi: 8 Kauj Ruam

Video: Lub Digital Sign Server ntawm Raspberry Pi: 8 Kauj Ruam
Video: Kiosk mode Bruteforce Evasion with Flipper Zero 2024, Kaum ib hlis
Anonim
Lub Digital Sign Server ntawm Raspberry Pi
Lub Digital Sign Server ntawm Raspberry Pi

Ib Qho Pib Pib Phau Ntawv Qhia rau Corsica ntawm Raspberry PI

Cov cim digital muaj nyob txhua qhov txhia chaw. Koj pom lawv hauv tshav dav hlau, cov khw muag khoom, cov khw muag khoom thiab txawm tias txoj kev kaum. Koj tsis xav tau ntau qhov kev cai kho vajtse kim los tsim koj tus kheej lub cim kos npe. Cov Lus Qhia no qhia yuav ua li cas tsim lub digital signage server uas tuaj yeem tsav kaum tawm ntawm cov lus. Txhua lub vijtsam tuaj yeem yooj yim xws li saib thiab Raspberry PI.

Ua tsaug rau Node Ninjas ntawm Mozilla koj tseem tuaj yeem ua haujlwm server ntawm Raspberry Pi siv Corsica.

Corsica yog kev daws teeb meem digital kos npe uas tuaj yeem siv tau rau feem ntau ntawm POSIX systems. Nws suav nrog tus neeg rau zaub mov thiab tso saib cov neeg siv khoom. Cov neeg siv lub tshuab tsis xav tau software tshwj xeeb thiab yooj yim siv txhua lub vev xaib niaj hnub no, txawm hais tias txhua tus neeg hauv pab pawg Corsica tsis pom zoo Firefox. Tus neeg rau zaub mov siv cov peev txheej tsawg heev thiab yuav zoo siab khiav ntawm Raspberry Pi lossis lwm lub tshuab me me. Corsica server khiav ntawm Raspberry Pi 3+ tuaj yeem yooj yim txhawb ntau dua 100 tus neeg siv khoom qhia. Cov lus qhia no tau sau tshwj xeeb rau Raspberry Pi uas khiav Raspian operating system (Debian derivative). Cov lus qhia no tseem xav tias koj siv Firefox browser. Feem ntau lwm qhov browser niaj hnub no yuav tsum ua haujlwm.

Kauj Ruam 1: Raspian Command Line

Cov lus qhia no yuav qhia koj yuav teeb tsa Corsica li cas los ntawm kab hais kom ua. Yog tias koj siv Raspian nrog cov duab siv sib tham (GUI), koj mus rau kab hais kom ua los ntawm daim ntawv thov davhlau ya nyob twg. Yog tias koj tab tom khiav Raspian-lite ces koj tuaj yeem txuas cov keyboard thiab saib xyuas thiab siv kab hais kom ua ncaj qha, lossis koj tuaj yeem txuas hla lub network siv SSH. Yog xav paub ntau ntxiv txog yuav ua li cas thiab siv SSH saib Raspian SSH cov ntaub ntawv. Koj yuav tsum paub lub npe DNS lossis tus IP chaw nyob ntawm koj li Raspberry Pi. Lub npe tsis raug ntawm feem ntau LANs yuav yog raspberrypi.local. Yog tias tsis ua haujlwm, muaj cov lus qhia hauv Raspian cov ntaub ntawv uas yuav pab koj tshawb pom lub npe raug thiab IP chaw nyob.

Kauj Ruam 2: Kev Txhim Kho Software

Corsica siv node thiab npm. Node cia koj khiav server-side Javascript, thiab npm yog node pob tus thawj tswj hwm.

Txhawm rau teeb tsa cov no ntawm Raspberry Pi thawj zaug tshuaj xyuas cov txheej txheem ntawm koj lub cev:

npe- m

Yog tias qhov tshwm sim pib nrog armv6, saib cov ntawv blog no. Rau Raspberry Pi 3 systems thiab lwm tus nrog armv7 thiab cov txheej txheem tom qab:

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E tsoo -

sudo apt nruab nodejs

Yog tias koj tsis paub nrog Node, koj tuaj yeem kawm paub ntau ntxiv ntawm nodesource.com.

Tom ntej no, teeb tsa Corsica Command Line Tools:

sudo npm nruab -g corsica -cli

Txhawm rau pom cov lus txib muaj, ntaus

corsica -pab

Raws li qhov kev sau no cov lus txib muaj yog:

teeb tsa-teeb tsa Corsica serverstart [xaiv]-los pib Corsica server rov pib dua [xaiv]-kom rov pib dua Corsica serverstop-kom nres Corsica ua haujlwm pabcuam-npe [npe]-txhawm rau txhim kho plugin-tshem tawm plugin [lub npe]-kom tshem tawm qhov teeb tsa pluginlist-plugins-kom teev cov plugins hloov kho tshiab-hloov kho ob qho Corsica thiab nws cov plugins

Tam sim no koj tuaj yeem siv cov cuab yeej los teeb tsa Corsica software:

teeb tsa corsica

Corsica teeb tsa yuav nug qhov twg koj xav teeb tsa corsica thiab qhia koj qhov chaw nyob tsis raug:

Qhov twg los teeb tsa Corsica: (/home/pi/corsica-server)

Koj tuaj yeem yooj yim nias rov qab.

Koj yuav pom qee cov lus ceeb toom npm. Cov no muaj kev nyab xeeb tsis quav ntsej.

Thaum teeb tsa hais tias "Ua tiav!", Koj tau teeb tsa Corsica.

Koj tuaj yeem pib Corsica hauv koj qhov kev sib tham dav dav nrog:

corsica pib

Thiab nres nws nrog tswj -C.

Tab sis yog tias koj pib nws li ntawd nws tsuas yog ua haujlwm ntev li ntev tau koj lub davhlau ya nyob twg sib ntsib. Thaum koj kaw koj lub davhlau ya nyob twg sib tham corsica yuav nres.

Yog tias koj pib Corsica hauv keeb kwm yav dhau nws yuav ua haujlwm txawm tias tom qab koj txuas koj lub davhlau ya nyob twg. Koj tuaj yeem ua qhov ntawd nrog

corsica pib -rov qab

Txhawm rau nres Corsica piv txwv ua haujlwm hauv keeb kwm yav dhau, ntaus:

nres corsica

Kauj ruam 3: Kev teeb tsa

Koj teeb tsa yuav zaum xav tau qee qhov kev hloov kho. Muaj ob hom kev hloov kho hauv Corsica: teeb tsa thiab teeb tsa. Kev teeb tsa feem ntau zoo li qub thiab siv los ntawm cov tub ntxhais. Cov chaw tau hloov pauv thiab siv feem ntau los ntawm plugins. Xav paub ntau ntxiv tom qab.

Kev teeb tsa los ntawm ib puag ncig, thiab yog rau yam zoo li qub xws li chaw nres nkoj kom mloog, lossis cov plugins kom thauj khoom. Muaj plaub qhov chaw rau kev teeb tsa:

1. lib/config.json - Qhov no yog qhov chaw khaws cia tsis raug, thiab qhov chaw zoo kom pom qee yam uas tuaj yeem teeb tsa. Koj yuav tsum tsis txhob hloov qhov txiaj ntsig ntawm no.

2. config.js - Cov chaw pom hauv cov ntawv no tau thauj khoom zoo li yog los ntawm ib puag ncig. Cov syntax yog ib qho teeb tsa ib kab, piv txwv li. PORT = 8080`. Yog tias qhov txiaj ntsig ntawm no siv tau JSON, lawv yuav raug cais raws li qhov ntawd. Kev teeb tsa ntawm no yuav thim qhov ua tsis tiav hauv 'lib/config.json`. Cov ntaub ntawv config.js pib qhia tus lej chaw nres nkoj uas Corsica mloog, thiab cov plugins siv los ntawm lub kaw lus.

3..env - Yog tias cov ntaub ntawv zais npe.env nyob hauv Corsica phau ntawv teev npe, nws cov chaw teeb tsa zoo li yog los ntawm ib puag ncig. Cov syntax yog tib yam li hauv config.js. Cov ntaub ntawv no tsis muaj nyob hauv kev teeb tsa ua ntej.

4. Kev hloov pauv ib puag ncig - Koj tuaj yeem tso cov ntaub ntawv teeb tsa hauv qhov hloov pauv ib puag ncig yog tias koj xav tau. Yog tias koj tsis paub nrog ib puag ncig hloov pauv nws muaj kev nyab xeeb tsis quav ntsej qhov kev xaiv no.

Kauj Ruam 4: Txuas Txuas Cov Vijtsam

Thaum koj pib Corsica nws yuav khiav lub vev xaib ntawm chaw nres nkoj 8080 ntawm koj lub tshuab tshwj tsis yog koj tau hloov tus lej chaw nres nkoj hauv.env cov ntaub ntawv. Koj yuav tsum paub tus tswv lub npe lossis tus IP chaw nyob ntawm koj tus Pi. Lub npe tsis raug rau Raspberry Pi tshiab teeb tsa yog raspberrypi. Yog tias koj tsis tau hloov nws koj tsuas tuaj yeem qhib qhov browser ntawm koj lub tshuab siv khoom thiab tshawb rau:

raspberrypi.local: 8080

Koj yuav tsum pom lub logo Corsica daj thiab dub. Lub npuas yuav tshwm nrog Corsica lub npe ntawm koj cov neeg siv khoom. Koj tuaj yeem (thiab yuav tsum tau) hloov lub npe ntawm koj cov neeg siv khoom rau qee yam uas qhia txog qhov chaw nyob ntawm lub vijtsam tshwj xeeb no. Txoj hauv kev yooj yim tshaj plaws los ua qhov no yog siv Potch's corsica-repl. (Potch yog tus tsim thawj ntawm Corsica, thiab nws tau cog lus tias yuav muab rov qab rau hauv qhov tseem ceeb ntawm Corsica qee lub sijhawm sai sai no).

Qhib qhov browser tab thiab xauj mus rau:

potch.github.io/corsica-repl?server=https://raspberrypi.local:8080/

(Uas xav tias raspberrypi.local yog lub npe ntawm koj Corsica Server).

Peb yuav siv "TestClient" raws li lub npe ntawm cov neeg siv khoom tso rau qhov seem ntawm kev qhia no. Mus rau qhov nco hauv lub kaum sab xis sab xis ntawm lub vijtsam thiab nrhiav tus neeg siv lub npe uas tshwm tuaj. Tom qab ntawd hauv kab hais kom ua hauv qab sab laug ntawm qhov screen hom:

admin hom = hloov npe lub npe = TestClient

Tawm ntawm corsica-rov tab qhib thiab hloov mus rau browser tab uas qhia Corsica lub logo thiab rov ua dua nplooj ntawv. Koj yuav pom lub npe tshiab hauv cov pop-up npuas. Yog tias nws ploj mus sai, yuj koj tus nas hauv qab kaum sab xis thiab khawm "Fullscreen" yuav tshwm nrog lub npe tshiab rau sab laug.

Kauj ruam 5: Ntxiv Cov Ntsiab Lus

Ntxiv Cov Ntsiab Lus
Ntxiv Cov Ntsiab Lus

Tom qab tso saib Corsica lub logo tus neeg siv khoom yuav tso saib qee cov tsiaj tas luav ntawm keeb kwm xiav.

Lub cim npe tag hauv lub xeev.json cov ntaub ntawv muaj cov npe ntawm nplooj ntawv web page. Koj tuaj yeem nthuav qhia txhua lub vev xaib li no, txawm hais tias kev teeb tsa ntawm qee nplooj ntawv ua rau lawv tsis haum rau siv nrog Corsica.

Corsica tus neeg siv khoom nthuav qhia cov ntsiab lus los ntawm ib lossis ntau daim ntawv cim npe uas nws tau sau npe. Cov neeg siv khoom tshiab tuaj twb tau sau npe rau ib lub npe hu ua "default".

Cov tsiaj tas luav tau ntxim hlub, tab sis cia peb ntxiv qee cov ntsiab lus muaj txiaj ntsig rau kev tshuaj ntsuam tig ntawm peb cov neeg siv khoom sim.

Rov qab mus rau corsica-repl tab thiab hauv kab hais kom ua ntawm sab laug sab laug:

admin hom = subscribe tag = huab cua

Hloov rov qab mus rau cov neeg siv khoom tab thiab rov ua dua nplooj ntawv.

Kev kwv yees huab cua rau San Jose, California, yuav raug ntxiv rau hauv cov npe url tso tawm.

Peb cov ntaub ntawv hauv xeev.json muaj peb daim ntawv hu ua "default", "weather" thiab "images". Cov ntawv "duab" muaj cov kab ntawv txuas rau ntau daim duab tsiaj tsiaj (.png). Cia peb ntxiv cov ntawd los ntawm kev hloov rov qab mus rau corsica-repl tab thiab ntaus:

admin hom = subscribe tag = duab

Ib zaug ntxiv, rov qab mus rau cov neeg siv khoom tab thiab rov ua dua nplooj ntawv. Koj yuav pom qee cov tsiaj tshiab ntxiv rau kev sib hloov. Tab sis ceeb toom tias cov tsiaj tshiab tshwm ntawm sab laug ntawm nplooj ntawv nrog keeb kwm yav dhau dawb. Qhov ntawd vim tias cov duab tas luav nrog rau keeb kwm yav dhau los xiav tau teev tseg hauv xeev.json raws li url uas taw tes rau lub vev xaib raug cai sau hauv html. Cov duab tas lauv tshiab nrog rau keeb kwm yav dhau los dawb tau teev tseg hauv xeev.json raws li url uas tsuas yog taw tes rau-p.webp

Peb tuaj yeem txhim kho txoj kev uas cov duab tau pom los ntawm Corsica, tab sis ua li ntawd peb yuav tau "nthuav" Corsica nws tus kheej.

Kauj Ruam 6: Txuas Corsica

Ntev Corsica
Ntev Corsica

Ntau tshaj kaum tawm npm Corsica plugins muaj nyob ntawm npm lub vev xaib. Ua raws qhov txuas ntawd thiab nkag mus rau "corsica" hauv kab ntawv tshawb fawb nyob rau sab saum toj ntawm nplooj ntawv kom pom cov npe ntawm lawv. Peb yuav siv ib qho ntawm cov npm plugins los qhia rau koj pom peb cov tsiaj tshiab. Nws kuj tseem muaj txiaj ntsig los tso saib cov duab uas koj pom hauv lub vev xaib, yam tsis muaj kev cuam tshuam cov duab cuam tshuam ib puag ncig cov duab.

Mus rau Corsica hais kom ua kab, nres Corsica thiab teeb tsa corsica-duab plugin:

corsica ntxiv-plugin corsica-duab

Tom qab ntawd rov pib dua corsica:

corsica pib

Qhib corsica tso saib cov neeg siv khoom tab ntawm koj tus browser thiab rov ua nplooj ntawv tshiab. Koj yuav tsum pom cov tsiaj tshiab tso rau hauv nruab nrab ntawm lub vijtsam nrog rau yav tsaus ntuj xiav.

Kauj Ruam 7: Kho Cov Ntsiab Lus

Cia peb saib qhov sib txawv ntawm qhov url hauv daim ntawv cim npe ua thiab cov nyob hauv cov duab cim npe. Saib hauv xeev.json los ntawm kev mus rau Corsica kab hais kom ua thiab ntaus:

miv ~/corsica-server/state.json

Hauv ntu "default" ntawm cov ntawv ntawd koj yuav pom kab uas zoo li:

"https://ramilewski.github.io/corsica-support/show.html?image=kitty.png", Qhov url no yog qhov txuas rau nplooj ntawv web uas muaj duab tas luav ntawm tus menyuam miv. Lub vev xaib ntawd nthuav tawm cov duab, tab sis nws kuj tseem muab cov keeb kwm yav dhau los uas yog qhov gradient uas pib nyob rau sab saum toj ntawm nplooj ntawv yog xim xiav, thiab ploj mus rau dawb nyob hauv qab ntawm nplooj ntawv. Lub keeb kwm yav dhau ntawd yog tsim los ntawm CSS thiab HTML ntawm nplooj ntawv web. Nws tsis yog ib feem ntawm daim duab nws tus kheej.

Tshooj "duab" ntawm nplooj ntawv muaj kab uas zoo li:

"https://ramilewski.github.io/corsica-support/bunny.png bg =#2244BB", Nov yog qhov url uas qhia meej txuas mus rau-p.webp

"#2244BB" yog tus lej hexadecimal rau xim xiav tsaus. Txog cov cuab yeej los pab koj txheeb xyuas cov xim hauv hex cov cim pom MDN Xim Xaiv.

Hauv kev nthuav tawm txoj kab no Corsica tau siv corsica-duab plugin los ua cov zaub. Qhov no txhais tau tias yog koj pom cov duab koj xav tso rau ntawm koj li Corsica cov neeg siv khoom, koj tuaj yeem tsim kab hauv xeev.json uas yuav tso tawm cov duab ntawd nkaus xwb, tab sis tsis muaj lwm yam cuam tshuam ntawm nplooj ntawv ib puag ncig. Txhawm rau nrhiav qhov url ntawm cov duab hauv Firefox, nyem rau ntawm daim duab thiab xaiv "Luam Qhov Chaw Duab" hauv cov ntawv qhia zaub mov uas tshwm.

Ntu "huab cua" ntawm state.json tsuas muaj ib qhov url xwb. Qhov no nqa cov huab cua los ntawm https://forecast.io. Tab sis tshwj tsis yog koj nyob hauv San Jose, qhov kev kwv yees ntawd tsis muaj txiaj ntsig zoo. Txhawm rau kom tau txais kev kwv yees rau koj qhov chaw koj yuav tsum paub nws yog latitude thiab longitude hauv decimal degrees. Yog tias koj tsis ua, muaj lub web-based tool uas yuav qhia rau koj pom nws.

Tam sim no qhov url hauv kab hauv xeev.json uas qhia txog huab cua huab cua zoo li:

"https://forecast.io/embed/#lat=37.3352&lon=-121.8871&name=San%20Jose%20CA&color=#4466bb zoom = 300"

Txhawm rau tau txais kev kwv yees rau koj qhov chaw nyob, hloov lat thiab lon nkag hauv kab ntawd thiab hloov lub npe rau koj qhov chaw nyob. Siv %20 hloov chaw ntawm qhov chaw npe. Cov xim ntsuas qhia xim ntawm cov tuav ntawm qhov siab thiab qis kub. Qhov ntsuas qhov ntsuas dav dav tau siv los kho qhov loj ntawm qhov kev kwv yees kom haum rau ntawm lub vijtsam zaub.

Thaum koj tsim koj tus kheej lub xeev.json cov ntaub ntawv, nco ntsoov tias yog tias koj muaj lub cim "default", txhua cov ntsiab lus tau teev tseg hauv daim ntawv ntawd yuav tshwm ntawm txhua lub browser uas txuas rau lub server yam tsis muaj teeb tsa ntxiv.

Zaub Sijhawm

Nyob rau sab saum toj ntawm xeev.json muaj qee qhov chaw uas tswj tau ntev npaum li cas cov duab tau tshwm ntawm qhov screen.

"nqis:: timer": {

"resetTime": 30000, "jitter": 5000, Txhua lub sijhawm raug ntsuas hauv milliseconds (txhiab thib ob ntawm ob). Lub sijhawm pib dua yog lub sijhawm ntau tshaj plaws uas txhua daim duab nyob ntawm lub vijtsam ua ntej lub vijtsam tom ntej tshwm. Jitter tau sib tw los ntawm tus lej tsis sib xws ntawm -1 thiab 1 thiab qhov txiaj ntsig tau ntxiv rau lub sijhawm pib. Qhov no muab qee yam sib txawv hauv cov sijhawm tso saib. Koj tuaj yeem teeb tsa jitter rau 0 yog tias koj xav tau. Cov teeb tsa pom yuav ua rau txhua nplooj ntawv pom ntawm 25 thiab 35 vib nas this.

Koj tseem tuaj yeem teev sijhawm sib txawv rau txhua tus neeg siv khoom saib:

"nqis:: timer": {

"resetTime": 30000, "jitter": 5000, "resetOnConnect": tseeb, "screens": {"TestClient": {"resetTime": 10000, "jitter": 1000}}}, Ntawm no peb tau teeb tsa lub sijhawm tso saib rau peb TestClient nyob nruab nrab ntawm 9 thiab 11 vib nas this.

Kauj Ruam 8: Xaus

Peb tau qhia yuav ua li cas rau nruab thiab teeb tsa Corsica server ntawm Raspberry Pi. Nrog yam koj tau kawm ntawm no, koj tuaj yeem tsim muaj ntau yam, tus nqi qis heev digital cov cim npe. Koj tuaj yeem siv Raspberry Pis tsis yog tsuas yog server hauv koj li kab ke, tab sis kuj tseem tsav cov neeg siv khoom nthuav tawm.

Muaj ntau ntau plugins ntawm npm lub vev xaib uas koj tuaj yeem siv los ntxiv lwm lub peev xwm rau koj kev teeb tsa Corsica, suav nrog tso saib:

  • Cov duab los ntawm Flickr
  • Tweets
  • Kev sib tham hauv IRC channel
  • Cov ntaub ntawv yees duab
  • YouTube yeeb yaj duab
  • Slides hauv Google nthuav tawm
  • XKCD tas luav
  • Cov ntsiab lus los ntawm RSS pub

Khab nias

Corsica yog kev tsim ntawm qib thib peb blackbelt Node Ninjas los ntawm Mozilla coj los ntawm cov lauj kaub, lonnen thiab mythmon.

Cov lus qhia no rau Corsica ntawm Raspberry Pis tau sib xyaw ua ke los ntawm Richard.

Feem ntau koj tuaj yeem pom txhua tus neeg nyob ib puag ncig #corsica channel ntawm irc.mozilla.org.

Pom zoo: