1

抱歉,这可能是一个完全的菜鸟问题

我从 github https://github.com/elfsternberg/The-Backbone-Store下载了一个主干示例应用程序,根据其自述文件,“必须安装在网络服务器下才能正常运行”。实际上,当我在 Chrome 中打开索引文件时,它只显示一个没有 javascript 功能的 html/css,并出现此错误

XMLHttpRequest cannot load file:///Users/me/Sites/backbonestore/data/items.json. Origin null is not allowed by Access-Control-Allow-Origin.

我认为这可能是因为 json 数据文件中的这些链接

"url": "http://www.amazon.com/Door-Religious-Knives/dp/B001FGW0UQ/?tag=quirkey-20"

该教程说我需要一个网络服务器,即使它不使用数据库。

当我不使用 Rails 时,有没有办法使用 webkit(我通常在 Rails 环境中工作)?如果这不是问题,那么你能解释一下我如何让它工作吗?

这个主干项目和我看过的其他项目之间的一个区别是它有一个 make 文件。我必须对此做些什么吗?

制作文件

.SUFFIXES: .nw .js .pdf .html .tex 

NOTANGLE=       notangle
NOWEAVE=        noweave
ECHO=           /bin/echo

all: index.html store.js 

.nw.html:
    $(NOWEAVE) -filter l2h -delay -x -index -autodefs c -html $*.nw > $*.html

.nw.tex:
    $(NOWEAVE) -x -delay $*.nw > $*.tex             #$

.tex.pdf:
    xelatex $*.tex; \
    while grep -s 'Rerun to get cross-references right' $*.log; \
        do \
        xelatex *$.tex; \
    done

.nw.js:
    @ $(ECHO) $(NOTANGLE) -c -R$@ $<
    @ - $(NOTANGLE) -c -R$@ $< > $*.nw-js-tmp
    @ if [ -s "$*.nw-js-tmp" ]; then \
        mv $*.nw-js-tmp $@; \
    else \
        echo "$@ not found in $<"; \
    rm $*.nw-js-tmp; \
    fi  

store.js: backbonestore.nw
    @ $(ECHO) $(NOTANGLE) -c -R$@ $<
    @ - $(NOTANGLE) -c -R$@ $< > $*.nw-html-tmp
    @ if [ -s "$*.nw-html-tmp" ]; then \
        mv $*.nw-html-tmp $@; \
    else \
        echo "$@ not found in $<"; \
    rm $*.nw-tmp; \
    fi  

index.html: backbonestore.nw
    @ $(ECHO) $(NOTANGLE) -c -R$@ $<
    @ - $(NOTANGLE) -c -R$@ $< > $*.nw-html-tmp
    @ if [ -s "$*.nw-html-tmp" ]; then \
        mv $*.nw-html-tmp $@; \
    else \
        echo "$@ not found in $<"; \
    rm $*.nw-tmp; \
    fi  


clean:
    - rm -f *.tex *.dvi *.aux *.toc *.log *.out *.html *.js

realclean: clean
    - rm -f *.pdf
4

2 回答 2

1

这里的问题可能是您正在尝试访问 chrome 中的应用程序,并且 chrome 中存在一个已知问题,如果您看到文件路径以file:///而不是开头,则无法打开文件路径file://事实上您可以使用任何 Web 服务器您可以通过 localhost url 访问这些路径。尝试在 Firefox 中打开同一个文件,它应该可以正常工作

于 2012-09-27T01:32:55.443 回答
0

您可以尝试安装一个小型静态文件 Web 服务器,例如node-static。只需npm install -g node-static(需要node.js),然后 - 在您的The-Backbone-Store/目录中 - 键入static. 您现在应该可以通过访问来使用http://localhost:8080

于 2012-09-26T21:24:28.203 回答