【问题标题】:Coffee Script Replace咖啡脚本替换
【发布时间】:2015-02-04 07:35:58
【问题描述】:

发现了这款名为 Ubersicht 的新应用。它似乎是 mac 上一个不错的 GeekTool 桌面替代品,小部件使用咖啡脚本。

我发现了一个很棒的脚本: https://github.com/bgartenmann/uebersicht-only-this-widget

脚本没有说明。它引用桌面上名为 today.txt 的文本文件。我们的想法是将您当天的任务放入小部件中。

 todayfile = '~/Desktop/today.txt'

 command: "cat #{today file}"

 refreshFrequency: 5000

 style: (a long list of css went here, did not think it was relevant)

 render: (output) -> 
 placeholder = "_____________"
 outputArray = output.split "*"
 goal = outputArray[0] || placeholder
 step1 = outputArray[1] || placeholder
 step2 = outputArray[2] || placeholder
 step3 = outputArray[3] || placeholder

    <p>If nothing else, today I am going to <span class="fillout">#{goal}</span>.<br />
     I am going to do this by <span class="fillout">#{step1}</span> then <span class="fillout">#{step2}</span> then <span class="fillout">#{step3}</span>.<br />
     <span class="motivation">If I do this and only this,<br /> today will be a <strong>good</strong> day.</span>"

我不知道如何格式化 .txt 文件中的条目,以便条目最终位于小部件上的正确位置。我尝试了多种方法来引用 step1 ,一个例子是..

step1 = "这一步"

每当我插入文本时,它们总是在第一行结束。我将如何使在 .txt 中输入的“任务”最终出现在小部件上的预期显示位置?

【问题讨论】:

    标签: javascript coffeescript geektool


    【解决方案1】:

    首先,感谢您宣传Übersichtthis widget!他们太棒了!

    ~/Desktop/today.txt 文件中项目的分隔符是星号 * 字符。

    这是我的~/Desktop/today.txt 的样子:

    answer a beyonddynamic’s question on stackoverflow
    *
    reading widget’s source code
    *
    taking a screenshot
    *
    posting an answer on stackoverfow
    

    如果您愿意,可以将句子写在一行上。新行是可选的。

    【讨论】:

    • 感谢杰夫!是的,它超级酷,甚至可能很容易使用,如果你不是一个总代码新手,啊哈。真的希望看到社区发展壮大。
    猜你喜欢
    • 2014-12-03
    • 2014-04-06
    • 2013-01-09
    • 2012-05-17
    • 1970-01-01
    • 2011-11-08
    • 2011-06-30
    • 2013-06-10
    • 2012-08-26
    相关资源
    最近更新 更多