Skip to content

Commit

Permalink
full commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin committed Jan 3, 2020
1 parent 6d4f755 commit 643beb9
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "venv3.6/bin/python"
}
12 changes: 12 additions & 0 deletions Untitled-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import boto3

# Let's use Amazon S3
s3 = boto3.resource('s3')

for bucket in s3.buckets.all():
print(bucket.name)

# Upload a new file
data = open('./static/favicon-32x32.png', 'rb')
s3.Bucket('thegratefulbrauer').put_object(Key='recipe_description_images/bbearce/recipes/favicon-32x32.png', Body=data)
11 changes: 6 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def load():

# Multiple row tables
for table in ['Fermentables','Hops']:
exec('{} = models.Recipe_{}.query.filter_by(recipe_id = Recipe.id).all()'.format(table, table))
exec('{} = models.Recipe_{}.query.filter_by(recipe_id = Recipe.id).all()'.format(table, table))

# Build data json dictionary based on models.

data = {'Recipe':{}}

data = {'Recipe':{}}

recipe_dict = {}
for r in recipe_columns:
Expand Down Expand Up @@ -138,9 +139,10 @@ def load():
@app.route('/save')
def save():

# Common to all
# Common to all (in db: gb_recipe_system)
recipe = request.args.get('recipe', 0, type=str)
style = request.args.get('style', 0, type=str)
notes = request.args.get('notes', 0, type=str)

# Grab all input values from html pages
for s in system_columns:
Expand Down Expand Up @@ -172,7 +174,7 @@ def save():
exec("{} = request.args.get('{}', 0, type=str)".format(c,c))

# check if this already exists
Recipe = models.Recipe(recipe=recipe, style=style)
Recipe = models.Recipe(recipe=recipe, style=style, notes=notes)

if(len(models.Recipe.query.filter_by(recipe=Recipe.recipe).all()) == 0):
print("this recipe doesn't exist so we are adding it.")
Expand Down Expand Up @@ -359,7 +361,6 @@ def brewculator():
hcolumns = [zip(hops_columns,[i]*(len(hops_columns)+1)) for i in range(1,num_of_inputs+1)]
hcolumns = [[j for j in i] for i in hcolumns] # Python3 has zips as generators so I have to convert


return render_template('/brewculator/brewculator.html',
Data = json.dumps(data),
Recipes=Recipes,
Expand Down
32 changes: 30 additions & 2 deletions static/css/brewculator.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,48 @@
height: 200px;
}

/* Home App START */
.home-app-div{
border-left: solid;
float: right;
width: 65%;
height: 500px;
}

#input-markdown {
height: 50%;
#notes {
height: 75%;
width: 100%;
font-size: 14pt;
text-align: left;
}

/* Floating Social Media Bar Style Starts Here */

.fl-fl {
color: #fff;
background: #000000;
text-transform: uppercase;
letter-spacing: 3px;
padding: 4px;
width: 190px;
position: fixed;
right: -140px;
z-index: 1000;
top: 180px;
font: normal normal 10px Arial;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}

.fl-fl:hover {
right: 0;
}

/* Home App END */

.fermentables-app-div{
border-left: solid;
float: right;
Expand Down
Binary file added static/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions static/js/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function convert_md_to_html(){
console.log('ran convert_md_to_html()')
// Get markdown to convert
var notes = document.getElementById('notes').value

var converter = new showdown.Converter();
var html = converter.makeHtml(notes);

var output_html = document.getElementById('output-html')
output_html.innerHTML = html

// Adjust what is shown
if (document.getElementById('notes').style.display === 'none') {
document.getElementById('notes').style.display = 'block'
document.getElementById('output-html').style.display = 'none'

} else {
document.getElementById('notes').style.display = 'none'
document.getElementById('output-html').style.display = 'block'

}
}

8 changes: 6 additions & 2 deletions static/js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ $('#load').bind('click', function() {

// Recipe
$('select[name="style"]').val(loaded_data['data']['Recipe']['gb_recipe_master']['style'])
$('textarea[name="notes"]').val(loaded_data['data']['Recipe']['gb_recipe_master']['notes'])

// System
$('input[name="batch_size"]').val(loaded_data['data']['Recipe']['gb_recipe_system']['batch_size'])
Expand Down Expand Up @@ -128,8 +129,12 @@ $('#load').bind('click', function() {
//Send User Message
alert("You just loaded "+loaded_data['data']['Recipe']['gb_recipe_master']['recipe'])


//// Rerun app calculations

// Load Notes and set to HTML mode
convert_md_to_html()

// Fermentables
refresh_fermentables()

Expand All @@ -151,8 +156,7 @@ $('#load').bind('click', function() {
// Fermentation
refresh_fermentation()




}


Expand Down
2 changes: 2 additions & 0 deletions static/js/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ $('#save').bind('click',
// Recipe
recipe: $('input[name="recipe"]').val(),
style: $('select[name="style"]').val(),
notes: $('textarea[name="notes"]').val(),


// System Table
batch_size: $('input[name="batch_size"]').val(),
Expand Down
1 change: 1 addition & 0 deletions templates/brewculator/brewculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ <h1>Brewculator</h1>
<script src="../static/js/water.js"></script>
<script src="../static/js/fermentation.js"></script>
<script src="../static/js/chemistry.js"></script>
<script src="../static/js/home.js"></script>

<!-- Load Script -->
<script src="../static/js/load.js"></script>
Expand Down
44 changes: 44 additions & 0 deletions templates/brewculator/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div class="container">
<div class='home-input-div'>
<!-- Home Section -->
<div style='display: block;'>
<label style='display: block;'>New Recipe Name</label>
<input type=text size=25 name=recipe style='text-align: left; ' value='new recipe'>
<input id=save type="button" value="Save">
</div>

<div>
<label style='display: block;'>Load Recipe</label>
<select id='recipe_load'>
{% for recipe in Recipes %}
<option> {{ recipe.recipe }}</option>
{% endfor %}
</select>
<input id=load type="button" value="Load">
</div>

<div>
<label style='display: block;'>Delete Recipe</label>
<select id='recipe_delete'>
{% for recipe in Recipes %}
<option> {{ recipe.recipe }}</option>
{% endfor %}
</select>
<input id=delete type="button" value="Delete">
</div>
</div>



<div class='home-app-div'>
<button id=convert_md_to_html onclick="convert_md_to_html()">Toggle MD and HTML</button>
<textarea id='notes' name='notes' type="text" style="display: block;">Enter New Recipe Notes</textarea>
<div id='output-html' style='display: none;'></div>
</div>

<div class="fl-fl">
<h2>Tool Bar</h2>
<a href="" target="_blank"> Like us!</a>
</div>

</div>

0 comments on commit 643beb9

Please sign in to comment.