Skip to content

Commit

Permalink
Merge pull request #72 from jtweeder/main
Browse files Browse the repository at this point in the history
Main to Dev
  • Loading branch information
jtweeder committed Jul 10, 2023
2 parents 164e222 + 7609903 commit d013acd
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 45 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Django CI

on:
push:
branches: [ "dev" ]
branches: [ "dev" , "main"]
pull_request:
branches: [ "dev" ]
branches: [ "dev", "main" ]

jobs:
build:
Expand Down Expand Up @@ -52,4 +52,7 @@ jobs:
POSTGRESPORT: 5432

run: |
python manage.py test
coverage run --source='.' manage.py test
coverage xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# mealcurator
[![Django CI](https://github.com/jtweeder/mealcurator/actions/workflows/django.yml/badge.svg)](https://github.com/jtweeder/mealcurator/actions/workflows/django.yml)
[![codecov](https://codecov.io/gh/jtweeder/mealcurator/branch/main/graph/badge.svg?token=35FD4Y6787)](https://codecov.io/gh/jtweeder/mealcurator)

Source code for Mealcurator.com

This is a Django Project that runs mealcurator.com. The source code here is just for the web-application itself. All AI tools are in the sister repository.
Expand Down
13 changes: 11 additions & 2 deletions meals/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from fractions import Fraction
import requests
import random
from bs4 import BeautifulSoup
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import uuid

from django.db import models
from django.contrib.postgres.indexes import GinIndex
from django.contrib.postgres.search import SearchVectorField
Expand Down Expand Up @@ -67,7 +67,16 @@ def pull_mstr(self):
return False

def _make_soup(self):
page = requests.get(self.rec_url)
user_agents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148',
'Mozilla/5.0 (Linux; Android 11; SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36'
]
user_agent = random.choice(user_agents)
headers = {'User-Agent': user_agent}
page = requests.get(self.rec_url, headers=headers)
if not page.ok:
raise ValueError(f'URL did not resolve to OK: {page.status_code}')
return BeautifulSoup(page.content, 'html.parser')
Expand Down
9 changes: 9 additions & 0 deletions meals/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required, user_passes_test
from django.urls import reverse_lazy
from django.views.generic.edit import CreateView, UpdateView, DeleteView
Expand Down Expand Up @@ -52,8 +53,16 @@ def form_valid(self, form):
outcome = raw.pull_mstr()
if outcome:
raw.mstr_flag = True
messages.add_message(
self.request, messages.INFO,
f'{raw.title} Successfully Created from: {raw.rec_url}')
else:
raw.error_flag = True
messages.add_message(
self.request, messages.INFO,
f'Sorry, Unable to Process {raw.title}'
f' from: "{raw.rec_url}".'
' We will attempt to add manually at a later date')
raw.save()
return redirect('get-recipe')

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ nltk==3.6.7
tst
lockfile==0.12.2
django-mailer==2.2
coverage==7.2.5
18 changes: 9 additions & 9 deletions templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

<h1>About mealCurator</h1>

<p>It all started with not having to do the same thing in reptition and enjoyment of cooking.</p>
<p>It all started with not having to do the same thing in repetition and enjoyment of cooking.</p>

<h2>Our Roots</h2>
<p>The orginial idea of mealCurator came from the fact that we enjoy cooking as a family, but I cannot cook anything without explicit instructions to follow. The interent has a vast amount of great recipes to choose from, but we struggled for an easy way to keep track of them.</p>
<p>The original idea of mealCurator came from the fact that we enjoy cooking as a family, but I cannot cook anything without explicit instructions to follow. The internet has a vast amount of great recipes to choose from, but we struggled for an easy way to keep track of them.</p>

<p>Like any good computer savy engineer type minded person. I decided instead of creating emails to myself, or writing down information. I would simply make a small app to solve the problem at hand. Storing recipes for the upcoming week in an easy to find and organized place. Something I could open from any device and have the recipes at my fingertips to start cooking.</p>
<p>Like any good computer savvy engineer type minded person, I decided - instead of creating emails to myself or writing down information - I would simply make a small app to solve the problem at hand. Storing recipes for the upcoming week in an easy to find and organized place. Something I could open from any device and have the recipes at my fingertips to start cooking.</p>

<p>A long time python programer and wanting to get some <a href="https://www.djangoproject.com/" target="_blank">Django</a> experience, I got to researching and then got to building. This is an ongoing side-project, and I am hopeful you find it useful. At the end of the day if you dont, I still got what I needed out of it, and got the Django Exposure I wanted.</p>
<p>A long time python programmer and wanting to get some <a href="https://www.djangoproject.com/" target="_blank">Django</a> experience, I got to researching and then got to building. This is an ongoing side project, and I am hopeful you find it useful. At the end of the day if you don't, I still got what I needed out of it, and got the Django Exposure I wanted.</p>

<p>If you are looking to get started with your own Djanog or WebApp check out the services of <a href="https://www.pythonanywhere.com/?affiliate_id=00bd0f8a" target="_blank">pythonanywhere</a>. They have a very affordable, and very easy to work with platform for folks that just want to worry about the programming side and leave the server side work to the pros. At the time of this writing we were able to stand-up a web-app, automated task, modest storage, and a small Postgres Database for the low monthly fee of $12. Once you out-grow that, it is easy to expand your computing profile with them. If you outgrow their services, it probably means you a miles above what I am trying to accomplish. The link above is my referall link if you do sign up for services a get kick-back on what you buy.</p>
<p>If you are looking to get started with your own Django or WebApp check out the services of <a href="https://www.pythonanywhere.com/?affiliate_id=00bd0f8a" target="_blank">pythonanywhere</a>. They have a very affordable, and very easy to work with platform for folks that just want to worry about the programming side and leave the server side work to the pros. At the time of this writing we were able to stand up a WebApp, automated task, modest storage, and a small Postgres Database for the low monthly fee of $12. Once you outgrow that, it is easy to expand your computing profile with them. If you outgrow their services, it probably means you're miles above what I am trying to accomplish. The link above is my referral link if you do sign up for services. I get kickback on what you buy.</p>

<h3>Finding Recipes</h3>
<p>The next problem to be solved was finding recipes that we would enjoy on the vast stretches of the internet. While it easy enough to pop 'quick XYZ meals' into google with a replacement of XYZ for whatever you are craving, it is easy to get burnt-out on meal-hunting on the internet. We solved the problem by building a database of meals we did know and then catagorizing them on various meta-data that made sense to us. With enough of these we will be automatically search the internet for new recipes or plop in a suggestion and let the computer do the lifting for us.</p>
<p>The next problem to be solved was finding recipes that we would enjoy on the vast stretches of the internet. While it's easy enough to pop 'quick XYZ meals' into Google with a replacement of XYZ for whatever you are craving, it is easy to get burned out on meal hunting on the internet. We solved the problem by building a database of meals we did know and then categorizing them on various metadata that made sense to us. With enough of these we will be automatically searching the internet for new recipes or plopping in a suggestion and letting the computer do the lifting for us.</p>

<p>Another problem that comes with finding recipes is the time you might invest in something that comes out just 'meh' or is a total waste of time and resources. So, from rating previous recipes we can start to build a profile of what we will like and grab similar recipes from what hopefully becomes very robust database of possible meals.</p>
<p>Another problem that comes with finding recipes is the time you might invest in something that comes out just 'meh' or is a total waste of time and resources. So, from rating previous recipes we can start to build a profile of what we like, and grab similar recipes from what hopefully becomes very robust database of possible meals.</p>

<h2>Our Plans</h2>
<p>The immediate goal is to get mealCurator up to a stable working version that checks the boxes that we intially set out to build. Once this accomplished we can get fancier and continuously add features to make mealCuartor even more useful. If you are savy with Django, HTML/CSS, or proof-reading, and want to contribute check out the <a href="https://github.com/jtweeder/mealcurator" target="_blank">Git Hub Repository</a>.</p>
<p>The immediate goal is to get mealCurator up to a stable working version that checks the boxes we intially set out to build. Once this is accomplished we can get fancier and continuously add features to make mealCurator even more useful. If you are savvy with Django, HTML/CSS, or proofreading and want to contribute check out the <a href="https://github.com/jtweeder/mealcurator" target="_blank">Git Hub Repository</a>.</p>

<h3>Supporting Us</h3>
<p>Currently the service is free and most likely keep a free option for the long term. The application does incur cost such as our pythonanywhere fees, domain fees, and beer fees to fuel the development. If you are generous, you can send some funds our way by contributing to our <a href="https://github.com/sponsors/jtweeder" target="_blank">github sponsorship</a>.</p>
<p>Currently the service is free and most likely we'll keep a free option for the long term. The application does incur cost such as our pythonanywhere fees, domain fees, and beer fees to fuel the development. If you are generous, you can send some funds our way by contributing to our <a href="https://github.com/sponsors/jtweeder" target="_blank">github sponsorship</a>.</p>

{% endblock page_content %}
4 changes: 2 additions & 2 deletions templates/attribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<h1>mealCurator Attribution Page</h1>

<p>
We depend on the open-source community, and creative common licensed for this site. This page reflects the vector graphics we have used, and the attribution to the creators that make them possible.
Please check out their other work and, if you are able support their work.
We depend on the open-source community, and creative common license for this site. This page reflects the vector graphics we have used, and the attribution to the creators that make them possible.
Please check out their other work and, if you are able, support their work.
</p>

{% for attribution in ccc %}
Expand Down
8 changes: 4 additions & 4 deletions templates/font_style.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ <h1>Welcome to mealCurator!</h1>
</p>
<h2>What is mealCurator?</h2>
<p>mealCurator is built to help you:
<li>Plan out your meals for whatever period of time ahead need</li>
<li>Plan out your meals for whatever period of time ahead needed</li>
<li>Provide a safe space to stash your planned meals</li>
<li>Links out to your planned meal so you can easily find that recipe</li>
<li>Do the hard work for you and find recipes for you</li>
<li>Do the hard work and find recipes for you</li>

<h2>Getting Started</h2>
<p>Getting started with mealCurator is easy. Simply create or login to your account. You can start building your first meal plan today.
<br>
<br>
Once logged in you can submit recipes you find around around the internet. Submitting recipes helps us build or databases and makes the overall platform more powerful. It typically takes about 10 minutes from submission of recipe until it is ready to be added to a meal plan. Sometimes certain websites will not allow us to collect enough information, or are behind a paywall. At this time these recipes wont be able to be added to a meal-plan.
Once logged in you can submit recipes you find around around the internet. Submitting recipes helps us build our databases and makes the overall platform more powerful. It typically takes about 10 minutes from submission of recipe until it is ready to be added to a meal plan. Sometimes certain websites will not allow us to collect enough information, or are behind a paywall. At this time these recipes wont be able to be added to a meal plan.
</p>
<h2>Issues</h2>
<p>The best place to look for a resolution to any problems will be in the <a href="{% url 'welcome' %}">'how-to'</a> section. Bugs are definatly going to appear. So if you have an issue that you cant solve with the how-to documentationa, feel free to submit an issue to the <a href="https://github.com/jtweeder/mealcurator" target="_blank">github repository</a> and we can take a look.
<p>The best place to look for a resolution to any problems will be in the <a href="{% url 'welcome' %}">'How-To'</a> section. Bugs are definately going to appear. If you have an issue that you can't solve with the How-To documentation, feel free to submit an issue to the <a href="https://github.com/jtweeder/mealcurator" target="_blank">github repository</a> and we can take a look.


{% endblock page_content %}
Loading

0 comments on commit d013acd

Please sign in to comment.