eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.47k stars 314 forks source link

Where is config.json? #90

Closed dangayle closed 9 years ago

dangayle commented 10 years ago

In the docs you mention a config.json file, but when I cactus create <foo>, there is no config file created. Where does it go?

krallin commented 10 years ago

Hi there,

If you are using Cactus v2, this file goes at the root of your project (so, just next to pages and others).

If you are using Cactus v3, this file goes wherever you want, just point Cactus to it with the CLI -c flag.

Cheers,

dangayle commented 10 years ago

Cactus doesn't create the file by default, so your instructions to "Modify config.json, and add the extensions you want to be fingerprinting," it makes no sense because there is no config.json file, and I don't know the data structure. Not meaning to be snarky, I really don't know what to do.

krallin commented 10 years ago

Config.json is a JSON object, and fingerprint should be a top level key.

{
      "fingerprint": [extensions here]
}

Please do feel free to submit a PR if you are unhappy with the state of the docs.

Cheers,

qaid commented 9 years ago

Thanks @krallin for helping to maintain the project. I was getting into Catus v2; now excited to make Cactus v3 work for me as well.

Sorry to seem daft, but using v3, if I use the CLI try to point Cactus to the config file in the root of a newly created project:

cactus -c config.json

I get the cactus: error: invalid choice error. All other actions are not possible until I get my config in place.

Any advice? Thanks in advance.

krallin commented 9 years ago

Hey @qaidj,

Does cactus -c config.json build work?

I can see that addinga "config-check command might be useful though. Is that what you're after?

Cheers,

qaid commented 9 years ago

Hmm .. no dice. Tried it and get the same error: invalid choice

Since the engine requires a config file, I have created one, but I can't get Cactus to recognize it. What would "config-check" do? Confirm format / existence?

krallin commented 9 years ago

Well, I'm not actually sure of what you're trying to achieve here: you're running Cactus without a command, so it tells you you need a command.

I'm sure you actually intend to do something else, but what is that?

(Sorry, the command above probably should have been cactus build -c config.json — if that still doesnt work, can you paste the CLI output and run cactus --help for me?).

Cheers,

qaid commented 9 years ago

Ah - it was indeed cactus build -c config.json that works.

Thanks for that!

(Just for clarity, I wasn't able to run cactus serve or cactus build, etc. without having a config file pointed to, so I was stuck there.)

krallin commented 9 years ago

What error did you get without a config file? Was that a bug?

I'll try and check whether we can accept -c regardless of where it is

Cheers,

qaid commented 9 years ago

I don't know enough about the way Cactus is supposed to give feedback to say it was a bug, but here are the details of what I tried:

Running webserver at http://127.0.0.1:8000 for /Users/me/my-junk/.build  
Type control-c to exit

I was able to access the project at this local URL. But was still getting the warning after save.

usage: cactus [-h]

              {messages:make,deploy,create,serve,domain:list,build,domain:setup}
              ...
cactus: error: invalid choice: 'config.json' (choose from 'messages:make', 'deploy', 'create', 'serve', 'domain:list', 'build', 'domain:setup')
krallin commented 9 years ago

Thanks for those details, @qaidj,

The error you were seeing was actually just a warning, but I can see how you'd think otherwise. I'll try and make this whole thing a little bit less confusing.

Cheers,

qaid commented 9 years ago

Good point - warnings, not errors.

Knowing that the full command of cactus build -c config.json was required was the only thing I needed.

thesues commented 9 years ago

Do you have an example file for config.json? I do not know where to put my aws key

krallin commented 9 years ago

@thesues ,

You can run cactus deploy without passing a config file and Cactus will:

Cheers,

fedelibre commented 9 years ago

cactus deploy is going to work only if you have an AWS account, otherwise it will break when you just hit enter when Amazon keys are asked. The error is cactus.exceptions.InvalidCredentials.

Back to the original question, I cannot make it work. I'm using version 3.02 installed from PyPI. Whatever I write in config.json is ignored (links are not prettified) and I keep getting the same warning:

$ cactus serve -c config.json 
Unable to load configuration at config.json
Running webserver at http://127.0.0.1:8000 for /home/fede/web/cactus/sixbarsjail.it/.build
Type control-c to exit

This is my config.json, at the root of the project:

{
  "site-url": "http://example.com/",
  "prettify": true,
}
krallin commented 9 years ago

@fedelibre ,

  1. I didn't understand your point regarding having an AWS account. Can you clarify? Did you mean you're trying to deploy to another provider and Cactus isn't prompting you for that?
  2. Your config.json is not valid JSON. There's a trailing comma. That's why it's not being loaded. IIRC we fixed that in master (the error is clearer now) but it might not be in the PyPi version yet (I have a small list of other fixes I'd like to make before pushing a new version).

Cheers,

fedelibre commented 9 years ago

I just pip installed from master.

  1. Well, I don't have an AWS account and AWS seems the only provider supported by cactus deploy. I hoped that cactus deploy could be used to generate a valid config.json and could ignore an empty value for AWS keys. It would be nice if it supported webfaction or, better, ssh configuration.
  2. Right, I don't know JSON. I just installed jsonlint (provided by python-demjson in debian). I should have removed the trailing comma after true.

BTW, the option -c is not documented in the help.. but it's also not needed, as cactus is able to find the config.json file (at least if in the root of the project).

krallin commented 9 years ago

Hey @fedelibre

You can actually set "provider" in your configuration to use one of the other supported deployment engines, which currently include "aws" (S3), "rackspace" (cloud files) and "google" (GCS).

Adding other providers is rather simple, but so far no one has worked on Webfaction or (s)ftp.

Cheers,

charliesneath commented 9 years ago

@krallin Thanks for the help in this thread. Agreeing with @dangayle that the language in the help doc is confusing as it implies config.json already exists, when it in fact needs to be created.

I am happy to update the language of the README.md so that it's more clear that config.json needs to be user generated.

Is there a reason that it can't be automatically created when the project is created?

krallin commented 9 years ago

@charliesneath I agree. Perhaps adding a default config.json is the right approach. That should be reasonably straightforward.

krallin commented 9 years ago

I've included a default config.json in the skeleton in https://github.com/koenbok/Cactus/commit/afa9bad5bbf556f6ce95c8f4d50c9e3ad1318aa9 — thanks for the suggestion!

charliesneath commented 9 years ago

@krallin Great, thank you!