itemsapi / starter

Create vertical search web application in minutes with generator (based on ItemsAPI)
Other
21 stars 15 forks source link

How to get pictures into ItemsAPI? #20

Open floppyapple123 opened 7 years ago

floppyapple123 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

Is it possible to upload a local file?

floppyapple123 commented 7 years ago

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

cigolpl commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

cigolpl commented 7 years ago

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 commented 7 years ago

How would I get here on Heroku?

cigolpl commented 7 years ago

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 commented 7 years ago

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

floppyapple123 commented 7 years ago

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

cigolpl commented 7 years ago

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 commented 7 years ago

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

floppyapple123 commented 7 years ago

Yeah I got that fixed.

On Tue, Jul 11, 2017 at 10:10 AM, Matt Rzepa notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/itemsapi/starter/issues/20#issuecomment-314475754, or mute the thread https://github.com/notifications/unsubscribe-auth/AcFAP2O3vDr_45OjtWKjtG5t_W_PVztOks5sM5BZgaJpZM4OS8O0 .

floppyapple123 commented 7 years ago

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 commented 7 years ago

Hello @floppyapple123, do you mean range aggregations like:

selection_280

or

selection_281

?

floppyapple123 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

image yeah it seems like an elasticsearch error

cigolpl commented 7 years ago

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 commented 7 years ago

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

cigolpl commented 7 years ago

@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 commented 7 years ago

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

floppyapple123 commented 7 years ago

So is there any way to see that?

On Thu, Jul 13, 2017 at 10:36 AM, Matt Rzepa notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/itemsapi/starter/issues/20#issuecomment-315115610, or mute the thread https://github.com/notifications/unsubscribe-auth/AcFAP_4J2bC4yLppKUZLFc5cxf8q1f-jks5sNjl7gaJpZM4OS8O0 .

floppyapple123 commented 7 years ago

image

cigolpl commented 7 years ago

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

floppyapple123 commented 7 years ago

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

floppyapple123 commented 7 years ago

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

cigolpl commented 7 years ago

Could you try again from scratch https://heroku.com/deploy?template=https://github.com/itemsapi/starter/tree/master ?

floppyapple123 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

cigolpl commented 7 years ago

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 commented 7 years ago

my app.json is the exact same as yours

floppyapple123 commented 7 years ago

does it work for you?

cigolpl commented 7 years ago

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 commented 7 years ago

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

floppyapple123 commented 7 years ago

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

cigolpl commented 7 years ago

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 commented 7 years ago

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

cigolpl commented 7 years ago

Wow, that's great about them :)

floppyapple123 commented 7 years ago

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 commented 7 years ago

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) ?