创建密码保护的日志

FarBox本身并不提供单日志的密码保护,但是,基于模板API,我们可以实现这个功能!

来源Oyiadin, 他提供的模板源码地址。

step1, 在显示文章列表里,对输出进行控制,如果有设定密码的(通过post.metadata.password判定),则使用如下的代码(Oyiadin将其放在include/password_form.jade这个文件中调用):

form(method="post", action="{{ post.url }}")
    p
        | 这是一篇受密码保护的文章,请提供
        if post.metadata.question
            | 问题的答案
        else
            | 密码
        | 以继续查看。

    label(for="password")
        {{ post.metadata.question or "密码:" }}
    input#password(name="password")
    //- 如果设置 type=password 的话,无法输入中文。
    input(type="submit", value="提交")

step2, 在文章的详细页中,对输入密码是否正确进行判断。

if not post.metadata.password or request.form.password|string == post.metadata.password|string
    post.content
 else
    include include/password_form

    if request.form.password|string
        p
            strong 输入错误,请重试。

注意事项

收密码保护的文章,在其它模板中,如果没有对应的逻辑,则是非密保的。

另外,文章的status不能为public, 因为可以通过?action=show_json来查看public的日志各种属性。

比如Oyiadin是用这种方式获取posts变量的:get_data(type='post', status=['public', 'secret'])

最终效果如图

Post Password

  • d2014-03-15 08:44

    Emz, looks nice!!!

  • Hey Ⅰ am so thгilled I fοund your webpage, I
    really found you by mistake, while I was researchіng on Dіgg for something else, Anyways I am herᥱ now and would just
    like to say kudos for a tremendous post and a all round entᥱrtaining blog (I also love the
    theme/design), I don’t have time to read it all at the minute but I haᴠe
    book-maгkeԁ it and also added youг RSS feeds, so when I
    have time I will be bаck to read much more, Please do keep up the grᥱat work.

  • derm exclusive tv offer2017-03-30 18:27

    Ꮲretty nice post. I simply stumbled upon your weblog and wanteԁ to mentiоn that I've trulү loved browsing your weblog
    posts. After aⅼl I wilⅼ be subscribing for
    your feed and I'm hoping you write once more very soon!

  • Mikki2018-08-09 08:23

    I'm not sure exactly why but this web site is loading very slow for me.

    Is anyone else having this problem or is it a problem on my end?
    I'll check back later on and see if the problem still exists.

  • pkmongobot2018-09-02 05:27

    aku metasa ini adalah salah satu dari begitu tidak sedikit berita utana bagi saya & aku
    senang mencarri ilmu artikel kamu namun harus di observasi
    kepada beberapa isu umum, cita rasa situs amat sangat
    ideal, artikelnya tefamat keren D. pekerjaan bagus sorak sorai.

  • 안전놀이터2018-09-23 08:37

    Hi! This is my first visit to your blog! We are a collection of volunteers and starting a new project in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a
    extraordinary job!

  • 모바일바카라2018-09-25 00:50

    Magnificent beat ! I would like to apprentice while
    you amend your site, how could i subscribe for a blog site?

    The account aided me a acceptable deal. I had been a little
    bit acquainted of this your broadcast offered bright clear concept

  • Danny2018-10-08 14:40

    博主你好,我想请问http://superdannyblog.farbox.com/我之前的这个模板在bitcron里面能否提供,现在因为没有这个模板一直迟迟没迁移过去。希望能够解答我这个疑惑。

  • 666.porn cheerleader sex2018-12-01 07:25

    Hey there! Someone in my Myspace group shared this website with us so I came to check it out.
    I'm definitely enjoying the information. I'm bookmarking and will be tweeting
    this to my followers! Great blog and amazing design and style.

  • Kennith2019-01-15 08:55

    Would you like to be abgle too defhse your fears or
    worries more frequently than it is possible to at present.
    Sometimes individuals have excessive responses of fear or anxiety
    to circukstances that do not cause these responses too others.
    Apart from alll of these the imbalance in tridoshas also cause impotence or erectile dysfunction.

  • 카지노사이트2019-01-17 21:54

    Have you ever thought about adding a little bit more than just your
    articles? I mean, what you say is fundamental and all.
    Nevertheless imagine if you added some great visuals or video clips
    to give your posts more, "pop"! Your content is excellent but with pics
    and video clips, this website could undeniably be one of the best in its field.
    Amazing blog!

  • 카지노사이트2019-01-18 18:30

    If some one needs expert view regarding blogging and site-building then i advise him/her to go to see this webpage, Keep up the good work.

  • 바카라사이트2019-02-08 17:51

    We recommend our casino, Baccarat site. Many of our members use our casino site to offer baccarat, slots, blackjack and roulette on a variety of platforms.
    My web page: https://www.mccasino777.com/

  • 카지노사이트2019-02-08 17:51

    Our casino representative Donald Net introduces only safe casino site Baccarat site among online casinos. Our casino-based baccarat site offers ducking casinos, yes casinos, first casinos and more.
    My web page: https://www.wac3636.com/

  • 카지노사이트2019-02-12 22:14

    Hi there! I simply want to offer you a big thumbs
    up for the great info you have got here on this post.

    I'll be coming back to your web site for more soon.

  • 바카라사이트2019-02-23 19:09

    I could not resist commenting. Exceptionally well written! https://www.bacca8.com/

  • 강남개인일수2019-02-28 15:11

    What's Going down i'm new to this, I stumbled
    upon this I've found It positively helpful and it has helped me out
    loads. I hope to contribute & help other users like its helped me.
    Good job.

  • acrylnagels2019-03-04 00:12

    This design is wicked! You definitely know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start my
    own blog (well, almost...HaHa!) Wonderful job. I really loved what you had to say, and more than that,
    how you presented it. Too cool!

  • agen sv3882019-04-03 16:12

    I am really enjoying the theme/design of your blog. Do
    you ever run into any internet browser compatibility problems?

    A number of my blog readers have complained about my website not operating correctly in Explorer but looks great in Safari.
    Do you have any advice to help fix this issue?

  • 명품레플리카2019-04-07 14:26

    Your mode of describing all in this post is in fact nice, all
    can without difficulty understand it, Thanks a lot.

  • 트위드자켓2019-04-20 03:05

    Greetings I am so glad I found your weblog, I really found you by error, while I
    was researching on Askjeeve for something else, Anyhow I
    am here now and would just like to say thank you for a fantastic post and a all round
    entertaining blog (I also love the theme/design), I don’t
    have time to read through it all at the minute
    but I have saved it and also added in your RSS feeds, so when I have time I will be back
    to read a lot more, Please do keep up the fantastic
    work.

  • sofa da2019-04-23 10:13

    I have to thank you for the efforts you've put in penning this blog.
    I really hope to check out the same high-grade blog
    posts from you in the future as well. In truth, your creative writing abilities
    has motivated me to get my own site now ;)

  • boekhouding breda2019-05-15 21:40

    If you wish for to get a good deal from this post then you
    have to apply such techniques to your won weblog.

  • 123Movies2019-05-17 16:29

    Hi, just want to say that I loved your article. Keep your working here.

  • FMovies2019-05-17 16:30

    Hard to ignore such an amazing article like this. You really amazed me with your writing talent. Thank for you shared again.

  • YesMovies2019-05-17 16:30

    I really enjoy your web’s topic. Very creative and friendly for users. Definitely bookmark this and follow it everyday.