Skip to content

Commit

Permalink
Merge pull request #4 from thinkle/master
Browse files Browse the repository at this point in the history
Merge upstream changes
  • Loading branch information
saxon-s authored Mar 1, 2019
2 parents fced1a4 + 81bb186 commit 9935ebf
Show file tree
Hide file tree
Showing 19 changed files with 538 additions and 381 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ Currently, our most pressing issues are:
* Some way to donate would be also nice (PayPal, gittip.com, Flattr,...?)
* Bug triaging. We have about [200 open issues](https://github.com/thinkle/gourmet/issues), and some of them are a couple of years old and have already been fixed. Some help in tagging, commenting, and ideally closing bugs is very welcome! (Note that to close a bug, you should really be sure it's okay to do so because you have tested Gourmet to work under the same conditions the bug reporter did.)

Make sure to also check out our upcoming [milestones](https://github.com/thinkle/gourmet/issues/milestones).
Make sure to also check out our upcoming [milestones](https://github.com/thinkle/gourmet/milestones).

More nifty ideas can be found via the [gsoc-idea label](https://github.com/thinkle/gourmet/issues?labels=gsoc-idea&page=1&state=open).
24 changes: 22 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,27 @@ for those options.

Mac OS X
--------
### Using MacPorts
### Installing with "Automatic Installation"
#### Using MacPorts
This guide will assume that the user does not already have any of the required packages installed. First, complete the following list of instructions to install MacPorts. These steps are reproduced from [MacPorts official instructions](https://www.macports.org/install.php).

1. Install Xcode and the Xcode Command Line Tools, accept the license.
1. Download Xcode from the App Store: [Link to download](https://itunes.apple.com/us/app/xcode/id497799835)
2. Run the following commands in Terminal

xcode-select --install
sudo xcodebuild -license
2. Install MacPorts for your version of the Mac operating system:
* [macOS High Sierra v10.13](https://distfiles.macports.org/MacPorts/MacPorts-2.5.3-10.13-HighSierra.pkg)
* [macOS Sierra v10.12](https://distfiles.macports.org/MacPorts/MacPorts-2.5.3-10.12-Sierra.pkg)
* [OS X El Capitan v10.11](https://distfiles.macports.org/MacPorts/MacPorts-2.5.3-10.11-ElCapitan.pkg)
* [Older OS? See here.](https://www.macports.org/install.php#installing)

With MacPorts installed, the command to install Gourmet is

sudo port install gourmet
### Installing From Source
#### Using MacPorts

To build gourmet from source, install the required dependencies as listed in the MacPorts column of the table below by running `sudo port install <dependencies>`.

Expand All @@ -44,7 +64,7 @@ You should then be able to launch gourmet by running

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/gourmet

### Using Fink
#### Using Fink

The following instructions all assume you have fink installed and that you have a terminal set up with the proper paths to run executables in the fink directories (/sw/bin/, etc.).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See [INSTALL.md](INSTALL.md).
Warning
=======

No warantee, etc. Please inform me of bugs/problems/feature
No warranty, etc. Please inform me of bugs/problems/feature
requests and I'll respond as quickly as I can. I can be reached
at [email protected]

Expand Down
24 changes: 18 additions & 6 deletions gourmet/OptionParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@

group = parser.add_mutually_exclusive_group()
group.add_argument('-q',action='store_const',const=-1,dest='debug',help='Don\'t print gourmet error messages')
group.add_argument('-v',action='count',dest='debug',help='Be verbose (extra v\'s will increase the verbosity level')
group.add_argument('-v',action='count',dest='debug',help='Be verbose (extra v\'s will increase the verbosity level)')

if has_argcomplete:
argcomplete.autocomplete(parser)

try:
args = parser.parse_args()
except:
print 'Maybe using django?'
print 'Then you can ignore this :)'
print 'args1 = %s' % args
except SystemExit as e:
import sys
sys.argv = ['gourmet']
args = parser.parse_args()

exc = sys.exc_info()[1]
if e.code is 0:
# Normal system exit
exit(e.code)
else:
print "Exception code: ", exc
argv = str(sys.argv[0])

if argv == "manage.py":
print 'Ignore the error message. Launching gourmetweb Django server ...'
sys.argv = ['gourmet']
args = parser.parse_args()
else:
# unrecognized argument
exit(e.code)
34 changes: 19 additions & 15 deletions gourmet/exporters/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,30 +464,33 @@ class ExporterMultirec (SuspendableThread, Pluggable):

name = 'Exporter'

def __init__ (self, rd, recipes, out, one_file=True, open_files = True,
ext='txt',
conv=None,
imgcount=1,
exporter=exporter,
exporter_kwargs={},
padding=None):
def __init__(self, rd, recipes, out, one_file=True, create_file=True,
ext='txt',
conv=None,
imgcount=1,
exporter=exporter,
exporter_kwargs={},
padding=None):
"""Output all recipes in recipes into a document or multiple
documents. if one_file, then everything is in one
file. Otherwise, we treat 'out' as a directory and put
individual recipe files within it.
@param one_file If True works in one_file mode. For this the class will
@param out: The name of the output file or directory
@param one_file: If True works in one_file mode. For this the class will
create the file which is accessible by self.ofi
If this is set to False a directory will be created and the
name of the directory will be passed via self.outdir and self.ofi
@param open_files If this parameter is True the files will be created
@param create_file: If this parameter is True the files will be created
otherwise to create the file is up to the user.
"""
self.timer=TimeAction('exporterMultirec.__init__()')
self.rd = rd
self.recipes = recipes
self.out = out
self.outdir = out
self.padding=padding
self.one_file = one_file
Pluggable.__init__(self,[BaseExporterMultiRecPlugin])
Expand All @@ -499,7 +502,7 @@ def __init__ (self, rd, recipes, out, one_file=True, open_files = True,
convert.FRACTIONS_ASCII)
self.DEFAULT_ENCODING = self.exporter.DEFAULT_ENCODING
self.one_file = one_file
self.open_files = open_files
self.create_file = create_file

def _grab_attr_ (self, obj, attr):
if attr=='category':
Expand Down Expand Up @@ -550,8 +553,9 @@ def do_run (self):
self.outdir=self.unique_name(self.outdir)
os.makedirs(self.outdir)
else: os.makedirs(self.outdir)
oneFileOpenByMyself = self.one_file and type(self.out) not in [str,unicode] and self.open_files
if oneFileOpenByMyself:
create_one_file = self.one_file and type(self.out) in [str, unicode] and self.create_file
create_multi_file = not self.one_file and type(self.out) in [str, unicode]
if create_one_file:
self.ofi=open(self.out,'wb')
else: self.ofi = self.out
self.write_header()
Expand All @@ -564,7 +568,7 @@ def do_run (self):
msg = _("Exported %(number)s of %(total)s recipes")%{'number':self.rcount,'total':self.rlen}
self.emit('progress',float(self.rcount)/float(self.rlen), msg)
fn=None
if multiFileOpenByMyself:
if create_multi_file:
fn=self.generate_filename(r,self.ext,add_id=True)
self.ofi=open(fn,'wb')
if self.padding and not first:
Expand All @@ -573,12 +577,12 @@ def do_run (self):
self.connect_subthread(e)
e.do_run()
self.recipe_hook(r,fn,e)
if multiFileOpenByMyself:
if create_multi_file:
self.ofi.close()
self.rcount += 1
first = False
self.write_footer()
if oneFileOpenByMyself:
if create_one_file:
self.ofi.close()
self.timer.end()
self.emit('progress',1,_("Export complete."))
Expand Down
2 changes: 1 addition & 1 deletion gourmet/plugins/import_export/epub_plugin/epub_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__ (self, rd, recipe_table, out, conv=None, ext='epub', copy_css=True,
self.exportargs['conv']=conv
ExporterMultirec.__init__(self, rd, recipe_table, out,
one_file=True,
open_files=False,
create_file=False,
ext=self.ext,
exporter=epub_exporter,
exporter_kwargs=self.exportargs)
Expand Down
20 changes: 14 additions & 6 deletions gourmet/plugins/web_plugin/gourmetweb/recview/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from django.http import HttpResponse, HttpResponseRedirect
from django import forms
from django.shortcuts import render_to_response
from django.template import Context, loader
import sys
sys.path.append('../../../')
import re
import gourmet.backends.db
import gourmet.shopping
import gourmet.recipeManager
from django.utils import simplejson
import json

from django.shortcuts import render


class MultiplierForm (forms.Form):
Expand Down Expand Up @@ -81,6 +83,12 @@ def do_search (request):
else:
print 'Not a post!'


def about(request):
return render(request, 'about.html')



def search (request, term, template='index.html'):
vw = rd.search_recipes(
[{'column':'deleted','operator':'=','search':False},
Expand Down Expand Up @@ -169,8 +177,8 @@ def multiply_rec (request, xhr=None):
'ingredients':get_ings(recid,multiplier),
'multiplier':multiplier}
return HttpResponse(
simplejson.dumps(d),
mimetype='application/javascript'
json.dumps(d),
content_type='application/javascript'
)
else:
return HttpResponseRedirect('/rec/%s/%s'%(recid,multiplier))
Expand Down Expand Up @@ -216,10 +224,10 @@ def shop_to_list (request):

def thumb (request, rec_id):
return HttpResponse(rd.get_rec(rec_id).thumb,
mimetype='image/jpeg'
content_type = 'image/jpeg'
)

def img (request, rec_id):
return HttpResponse(rd.get_rec(rec_id).image,
mimetype='image/jpeg'
content_type = 'image/jpeg'
)
Loading

0 comments on commit 9935ebf

Please sign in to comment.