Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get pictures into ItemsAPI? #20

Open
floppyapple123 opened this issue Jul 10, 2017 · 43 comments
Open

How to get pictures into ItemsAPI? #20

floppyapple123 opened this issue Jul 10, 2017 · 43 comments

Comments

@floppyapple123
Copy link

I want to get the pdf icon on all of my entries, but I don't really know how to do so. Could anyone explain how to? I'm running it off of Heroku. Thanks.

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

You need to provide image field in all your entries then it will be displayed automatically. Otherwise if you have different field in the object then you can customize it in the layout /views/catalog.html.twig

@floppyapple123
Copy link
Author

Is it possible to upload a local file?

@floppyapple123
Copy link
Author

Also, when I click on an item, is it possible to link it to a pdf file?

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

If you open /admin/images and configure AWS S3 then it should be possible to store images. Not sure how stable this feature was. It will be easier I guess if you provide link in your JSON file to external pdf / image

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

If you customize ./views/catalog.html.twig and ./src/routes.js then everything should be possible. This starter is based on http://expressjs.com/

@floppyapple123
Copy link
Author

Thanks. But can I link it to a opening pdf instead of going to this page? Thanks so much.
image

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

Just open ./views/catalog.html.twig and find a part:

<div class="items">
  {% for item in items %}
  <div class="col-xs-3 col-md-3" style="height: 220px;">
    <a href="{% if item.permalink %}/item/{{ item.permalink }}{% else %}/id/{{ item.id }}{% endif %}" class="">
      <img class="img-thumbnail" src="{% if item.image %}{{ item.image }}{% else %}{{ image }} {% endif %}" alt="{{ item.domain }}">
      <p>{{ item.domain }}</p>
    </a>
  </div>
  {% endfor %}
</div>

and then provide a link there to your pdf instead of going to /item/:id

@floppyapple123
Copy link
Author

How would I get here on Heroku?

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

You should run it on your localhost, modify and then redeploy. Not sure how to do it fast but I think this tutorial can be helpful https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction

@floppyapple123
Copy link
Author

you already answered my question on linkedin (sorry for asking twice), but thank you so much

@floppyapple123
Copy link
Author

floppyapple123 commented Jul 10, 2017

image
now I'm getting an error with the npm install :/ Elasticsearch and MongoDB are up and running

@cigolpl
Copy link
Member

cigolpl commented Jul 10, 2017

Oh, you are using windows. I've never tried that with windows. It might get more complicated. Ideally if you use linux. Vagrant can help you run a virtual machine i.e. ubuntu on your windows (https://www.vagrantup.com/intro/getting-started/).

You can also try docker composer which starts everything for you out of the box on all operating systems. (https://www.itemsapi.com/docs/starter/installation/). There are some updates thanks to @fbertetto which allows you to edit files locally on your windows and run that easily using docker compose. Not sure how convenient is a development with docker composer though.

@cigolpl
Copy link
Member

cigolpl commented Jul 11, 2017

Do you have mongodb installed on your localhost ? You can check it out by writing mongo in your CLI.

@floppyapple123
Copy link
Author

floppyapple123 commented Jul 11, 2017 via email

@floppyapple123
Copy link
Author

I got everything to work :), but how do you make a range value with ItemsAPI. Like how would I be able to input data saying that an item has been in use from 2340 to 23948 hours?

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Hello @floppyapple123, do you mean range aggregations like:

selection_280

or

selection_281

?

@floppyapple123
Copy link
Author

Yeah. Also, for some reason I'm stuck on this page
image
when I hit submit, it just takes refreshes the page and does not go on. I created the heroku app by cloning directly from the github page.

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Regarding 1)
There are some info about aggregations - https://www.itemsapi.com/docs/starter/aggregations/. Usually such a aggregations are created automatically by "understanding" data in the installation process and later you can customize them in the administration panel.

Regarding 2) (Getting stuck on installation page)
Heroku logs should provide you more information. You can find them using heroku cli or in dashboard. It can be a heroku problem (i.e. exceeded limit) or some elasticsearch error (some data error).

@floppyapple123
Copy link
Author

image
yeah it seems like an elasticsearch error

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Are you trying with a demo items https://raw.githubusercontent.com/itemsapi/itemsapi-example-data/master/items/movies-processed.json or a custom one ?

@floppyapple123
Copy link
Author

floppyapple123 commented Jul 13, 2017

it works for neither the demo items nor a custom one. The log i attached above is from the demo items

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

@floppyapple123 it can be a index limit from a Heroku external ES provider. I had such a problem in the past. I was testing now and it's working fine. You can try to remove some of your heroku apps and try again.

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Heroku is using https://bonsai.io/ for ES. Maybe there are also some error information in bonsai directly

@floppyapple123
Copy link
Author

floppyapple123 commented Jul 13, 2017 via email

@floppyapple123
Copy link
Author

image

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Not sure how to fix it. Maybe there is a limit in index amount and removing some of them will be a solution

@floppyapple123
Copy link
Author

I've already deleted all but two apps in my heroku

@floppyapple123
Copy link
Author

I've gotten it to run the same way before, i don't know why its messing up right now

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

@floppyapple123
Copy link
Author

Deploying from there works fine. The problem I'm having is that I need to edit the catalog.html.twig file, so I'm getting it locally, by going into CMD and hitting

$heroku login
(enter in my info)
$git clone https://github.com/itemsapi/starter.git
$cd starter
$heroku create
$git push heroku master
$heroku open

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Your method is great but I am getting then:

{
  "message": "unexpected error - probably mongodb is required"
}

Usually I was using https://heroku.com/deploy?template=https://github.com/itemsapi/starter/tree/master
and follow heroku instruction how to run it locally

selection_284

You will find it in https://dashboard.heroku.com/apps -> your app -> deploy

@floppyapple123
Copy link
Author

you have to go into heroku and go into the resources tab and manually add mongodb, bonsai elasticsearch and redis

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Nice, very tricky. Ensure you are using ES 1.7 in Bonsai.

When you are using https://heroku.com/deploy?template=https://github.com/itemsapi/starter/tree/master then it's defined in app.json https://github.com/itemsapi/starter/blob/master/app.json

In here:

selection_285

It is taking ES 5.3.2 probably

@floppyapple123
Copy link
Author

my app.json is the exact same as yours

@floppyapple123
Copy link
Author

does it work for you?

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

In this way (when I was adding addons by heroku web interface) no because bonsai created for me ES 5.3.2 version which is not supported and I couldn't find a way to change version..

selection_286

@floppyapple123
Copy link
Author

image
Hmm yeah its the same for me too. Is it possible to change it?

@floppyapple123
Copy link
Author

so is there any way to get itemsAPI locally and run it off heroku?

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Probably the easiest way to start (after heroku) is docker composer. Personally the best for me is linux ubuntu. It can be run on localhost with vagrant or also with https://www.digitalocean.com/. You can install all dependencies manually or with preconfigured ansible script.

https://www.itemsapi.com/docs/starter/installation/.

@floppyapple123
Copy link
Author

I emailed bonsai support and got downgraded to 1.7.5 and it works now :)

@cigolpl
Copy link
Member

cigolpl commented Jul 13, 2017

Wow, that's great about them :)

@floppyapple123
Copy link
Author

image
I see that you updated the Image uploader, but I'm still using AWS right now. It works fine as long as the files are made public, but I want to make it so that itemsAPI can access and display private files.

@cigolpl
Copy link
Member

cigolpl commented Aug 10, 2017

Hey, yes. How the private files work in AWS S3 - I mean how amazon is making the authentication for the private files (by IP, token) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants