我的网站在这里.
它曾经是一个Django支持的博客.但是我不再更新它,所以我只是想让它成为一个静态HTML站点.我想它并用Ruby Rack将它移动到Heroku.
但是,每个URL都会解析为主页.这是因为我的config.ru文件:
use Rack::Static,
:urls => ["/media/images", "/media/js", "/media/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
Run Code Online (Sandbox Code Playgroud)
问题:有没有办法映射多个URL?例如foo.com/about映射到public/about/index.html,foo.com/posts/2012/oct/21/blog-post映射到public/posts/2012/oct/21/blog-post/index.html
在这一点上,我甚至可以手动输入每一个.
谢谢你的帮助.
有没有办法关闭Recharts 中条形图悬停时出现的灰色背景?
使用版本 1.4.1。代码(简化)如下所示:
import React from "react"
// Recharts
import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts"
import CustomTooltip from "../CustomTooltip"
const BarChart = ({ chartData, chartInfo }) => (
<ResponsiveContainer width="99%" height={260}>
<BarChart data={chartData}>
<XAxis
dataKey="label"
type="category"
allowDuplicatedCategory={true}
tickLine={false}
orientation="bottom"
/>
<YAxis
tickLine={false}
orientation="left"
axisLine={false}
/>
<Tooltip
isAnimationActive={false}
separator={": "}
content={<CustomTooltip />}
/>
<CartesianGrid vertical={false} />
{chartInfo.map(bar => (
<Bar
key={bar.dataKey}
name={bar.name}
dataKey={bar.dataKey}
isAnimationActive={false}
/>
))}
</BarChart>
</ResponsiveContainer>
)
export default BarChart …Run Code Online (Sandbox Code Playgroud) 这是一个非常奇怪的过程.
我有一个UIButtons的IBOutletCollection.我遍历集合并像这样创建它们(displayHourButtons从中调用viewWillAppear):
- (void)displayHourButtons
{
// Counter
NSUInteger b = 0;
// Set attributes
UIFont *btnFont = [UIFont fontWithName:@"Metric-Semibold" size:13.0];
UIColor *btnTextColor = [UIColor colorWithRed:(147/255.0f) green:(147/255.0f) blue:(147/255.0f) alpha:1.0];
NSNumber *btnTracking = [NSNumber numberWithFloat:0.25];
NSMutableParagraphStyle *btnStyle = [[NSMutableParagraphStyle alloc] init];
[btnStyle setLineSpacing:2.0];
NSDictionary *btnAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
btnFont, NSFontAttributeName,
btnTextColor, NSForegroundColorAttributeName,
btnTracking, NSKernAttributeName, nil];
// CREATE THE BUTTONS
for (UIButton *hourButton in hourButtons) {
// I'm using the attributed string for something else
// later in development …Run Code Online (Sandbox Code Playgroud) 我试图通过ObjectId找到它来更新MongoDB中的文档.工作流程如下(这是针对博客).
第1步和第2步工作正常,但第3步似乎不起作用.它重定向到我需要它的页面.但数据库尚未更新.它与以前的价值相同.
以下是更新帖子部分的相关代码:
app.js
app.post "/office/post/:id/update", ensureAuthenticated, routes.updatePost
Run Code Online (Sandbox Code Playgroud)
路线/ index.js
mongoose = require 'mongoose'
ObjectId = mongoose.Types.ObjectId
Post = require '../models/Post'
...
updatePost: function(req, res) {
var o_id, the_id;
the_id = req.params.id;
console.log(the_id); // 510e05114e2fd6ce61000001
o_id = ObjectId.fromString(the_id);
console.log(o_id); // 510e05114e2fd6ce61000001
return Post.update({
"_id": ObjectId.fromString(the_id)
}, {
"title": "CHANGE"
}, res.redirect("/office/edit/posts"));
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Express和Mongoose.
如果有帮助,这也是帖子模型:
(function() {
var Post, Schema, mongoose;
mongoose = require('mongoose');
Schema = mongoose.Schema;
Post = new Schema({
title: String,
subhead: String,
body: String,
publish_date: …Run Code Online (Sandbox Code Playgroud) 我有一个 Node/React 项目,在我的package.json 中,如果我想运行一些简单的脚本,我可能会这样做:
{
"scripts": {
"prep": "cp -r this/sub-directory/path another/sub-directory/path"
},
}
Run Code Online (Sandbox Code Playgroud)
然后yarn prep执行它。
但是,在这种情况下,我有很多命令,比如 5-6,并且将它们全部放在 package.json 文件中的一行中会使阅读变得困难。
我想做的是将它们放在一个单独的文件中,然后调用该文件。类似于名为run-script的文件:
#!/bin/bash
echo 'test'
Run Code Online (Sandbox Code Playgroud)
然后在 package.json 中:
{
"scripts": {
"prep": "run-script"
},
}
Run Code Online (Sandbox Code Playgroud)
但这显然给了我错误,我不知道如何告诉它运行文件,它应该是什么扩展名等(我知道我可以做,"prep": "node run-script.js"但在这种情况下,我想做一些简单的事情,例如复制目录等,而不是 JavaScript 的东西。)
需要@roadowl的两种解决方案。
chmod ug+x run-script设置权限,然后$PWD在package.json 中调用文件的位置前面添加当前工作目录变量 ( ) :{
"scripts": {
"prep": "$PWD/run-script"
},
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有选择下拉列表的表单,其中包含通过循环对象构建的选项。每个选项都有一个关联的value属性和一个自定义属性data。
我可以检索value就好了,但我无法访问该data属性。我尝试遵循此处找到的 JavaScript 模式,但无济于事。返回的值为undefined。
这是带有表单的组件:
import React from 'react';
import Option from './Option';
class AddmenuItemForm extends React.Component {
createMenuItemTest(event) {
event.preventDefault();
const menuItem = {
subsectionObjectId: this.subsectionObjectId.value,
orderIndex: this.subsectionObjectId.selectedIndex.data,
}
this.props.addMenuItem(menuItem);
this.menuItemForm.reset();
}
render() {
const { subsections } = this.props;
return (
<div>
<form ref={(input) => this.menuItemForm = input} onSubmit={(e) => this.createMenuItemTest(e)}>
<select
ref={(input) => this.subsectionObjectId = input}
className="input mtm">
{
Object
.keys(subsections)
.map(key => …Run Code Online (Sandbox Code Playgroud)