소스 검색

Merge pull request #4165 from achillesrasquinha/develop

[MAJOR] WebCamera attachments, Desktop Wiggling, bench command, minor UX, better dev workflow, MariaDB@10.2 fix
version-14
Rushabh Mehta 7 년 전
committed by GitHub
부모
커밋
2248dbc819
20개의 변경된 파일380개의 추가작업 그리고 30개의 파일을 삭제
  1. +1
    -0
      .eslintrc
  2. BIN
      .github/logo.png
  3. +2
    -0
      .gitignore
  4. +3
    -0
      .vscode/settings.json
  5. +21
    -0
      LICENSE
  6. +2
    -0
      Makefile
  7. +28
    -5
      README.md
  8. +25
    -6
      frappe/build.py
  9. +3
    -2
      frappe/commands/utils.py
  10. +114
    -1
      frappe/core/page/desktop/desktop.js
  11. +13
    -0
      frappe/desk/doctype/desktop_icon/desktop_icon.py
  12. +8
    -1
      frappe/public/build.json
  13. +4
    -2
      frappe/public/js/frappe/form/controls/color.js
  14. +22
    -1
      frappe/public/js/frappe/form/controls/text_editor.js
  15. +94
    -0
      frappe/public/js/frappe/ui/capture.js
  16. +2
    -0
      frappe/public/js/lib/jquery.jrumble.min.js
  17. +2
    -0
      frappe/public/js/lib/webcam.min.js
  18. +0
    -9
      license.txt
  19. +1
    -1
      requirements.txt
  20. +35
    -2
      setup.py

+ 1
- 0
.eslintrc 파일 보기

@@ -54,6 +54,7 @@
"Taggle": true,
"Gantt": true,
"Slick": true,
"Webcam": true,
"PhotoSwipe": true,
"PhotoSwipeUI_Default": true,
"fluxify": true,


BIN
.github/logo.png 파일 보기

Before After
Width: 615  |  Height: 530  |  Size: 12 KiB

+ 2
- 0
.gitignore 파일 보기

@@ -9,3 +9,5 @@ locale
dist/
build/
frappe/docs/current
.vscode
node_modules

+ 3
- 0
.vscode/settings.json 파일 보기

@@ -0,0 +1,3 @@
{
"python.linting.pylintEnabled": false
}

+ 21
- 0
LICENSE 파일 보기

@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2016-2017 Frappé Technologies Pvt. Ltd. <developers@frappe.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

+ 2
- 0
Makefile 파일 보기

@@ -0,0 +1,2 @@
clean:
python setup.py clean

+ 28
- 5
README.md 파일 보기

@@ -1,9 +1,33 @@
## Frappé Framework

[![Build Status](https://travis-ci.org/frappe/frappe.png)](https://travis-ci.org/frappe/frappe)
<div align="center">
<img src=".github/logo.png" height="256">
<h1>
<a href="https://frappe.io">
frappé
</a>
</h1>
<h3>
a web framework with <a href="https://www.youtube.com/watch?v=LOjk3m0wTwg">"batteries included"
</h3>
<h5>
it's pronounced - <em>fra-pay</em>
</h5>
</div>

<div align="center">
<a href="https://travis-ci.org/frappe/frappe">
<img src="https://img.shields.io/travis/frappe/frappe.svg?style=flat-square">
</a>
<a href='https://frappe.io/docs'>
<img src='https://img.shields.io/badge/docs-📖-7575FF.svg?style=flat-square'/>
</a>
</div>

Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library. Built for [ERPNext](https://erpnext.com)

### Table of Contents
* [Installation](#installation)
* [License](#license)

### Installation

[Install via Frappé Bench](https://github.com/frappe/bench)
@@ -20,5 +44,4 @@ For details and documentation, see the website
[https://frappe.io](https://frappe.io)

### License

MIT License
This repository has been released under the [MIT License](LICENSE).

+ 25
- 6
frappe/build.py 파일 보기

@@ -4,6 +4,7 @@
from __future__ import unicode_literals, print_function
from frappe.utils.minify import JavascriptMinify
import subprocess
import warnings

from six import iteritems, text_type

@@ -25,12 +26,12 @@ def setup():
except ImportError: pass
app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules]

def bundle(no_compress, make_copy=False, verbose=False):
def bundle(no_compress, make_copy=False, restore=False, verbose=False):
"""concat / minify js files"""
# build js files
setup()

make_asset_dirs(make_copy=make_copy)
make_asset_dirs(make_copy=make_copy, restore=restore)

# new nodejs build system
command = 'node --use_strict ../apps/frappe/frappe/build.js --build'
@@ -60,7 +61,8 @@ def watch(no_compress):

# time.sleep(3)

def make_asset_dirs(make_copy=False):
def make_asset_dirs(make_copy=False, restore=False):
# don't even think of making assets_path absolute - rm -rf ahead.
assets_path = os.path.join(frappe.local.sites_path, "assets")
for dir_path in [
os.path.join(assets_path, 'js'),
@@ -80,11 +82,28 @@ def make_asset_dirs(make_copy=False):

for source, target in symlinks:
source = os.path.abspath(source)
if not os.path.exists(target) and os.path.exists(source):
if make_copy:
shutil.copytree(source, target)
if os.path.exists(source):
if restore:
if os.path.exists(target):
if os.path.islink(target):
os.unlink(target)
else:
shutil.rmtree(target)
shutil.copytree(source, target)
elif make_copy:
if os.path.exists(target):
warnings.warn('Target {target} already exists.'.format(target = target))
else:
shutil.copytree(source, target)
else:
if os.path.exists(target):
if os.path.islink(target):
os.unlink(target)
else:
shutil.rmtree(target)
os.symlink(source, target)
else:
warnings.warn('Source {source} does not exists.'.format(source = source))

def build(no_compress=False, verbose=False):
assets_path = os.path.join(frappe.local.sites_path, "assets")


+ 3
- 2
frappe/commands/utils.py 파일 보기

@@ -8,13 +8,14 @@ from frappe.utils import update_progress_bar

@click.command('build')
@click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking')
@click.option('--restore', is_flag=True, default=False, help='Copy the files instead of symlinking with force')
@click.option('--verbose', is_flag=True, default=False, help='Verbose')
def build(make_copy=False, verbose=False):
def build(make_copy=False, restore = False, verbose=False):
"Minify + concatenate JS and CSS files, build translations"
import frappe.build
import frappe
frappe.init('')
frappe.build.bundle(False, make_copy=make_copy, verbose=verbose)
frappe.build.bundle(False, make_copy=make_copy, restore = restore, verbose=verbose)

@click.command('watch')
def watch():


+ 114
- 1
frappe/core/page/desktop/desktop.js 파일 보기

@@ -112,13 +112,17 @@ $.extend(frappe.desktop, {
},

setup_module_click: function() {
frappe.desktop.wiggling = false;

if(frappe.list_desktop) {
frappe.desktop.wrapper.on("click", ".desktop-list-item", function() {
frappe.desktop.open_module($(this));
});
} else {
frappe.desktop.wrapper.on("click", ".app-icon", function() {
frappe.desktop.open_module($(this).parent());
if ( !frappe.desktop.wiggling ) {
frappe.desktop.open_module($(this).parent());
}
});
}
frappe.desktop.wrapper.on("click", ".circle", function() {
@@ -127,6 +131,115 @@ $.extend(frappe.desktop, {
frappe.ui.notifications.show_open_count_list(doctype);
}
});

frappe.desktop.setup_wiggle();
},

setup_wiggle: () => {
// Wiggle, Wiggle, Wiggle.
const DURATION_LONG_PRESS = 1000;
// lesser the antidode, more the wiggle (like your drunk uncle)
// 75 seems good to replicate the iOS feels.
const WIGGLE_ANTIDODE = 75;

var timer_id = 0;
const $cases = frappe.desktop.wrapper.find('.case-wrapper');
const $icons = frappe.desktop.wrapper.find('.app-icon');
const $notis = $(frappe.desktop.wrapper.find('.circle').toArray().filter((object) => {
// This hack is so bad, I should punch myself.
const doctype = $(object).data('doctype');
return doctype;
}));
const clearWiggle = () => {
const $closes = $cases.find('.module-remove');
$closes.hide();
$notis.show();

$icons.trigger('stopRumble');

frappe.desktop.wiggling = false;
};

// initiate wiggling.
$icons.jrumble({
speed: WIGGLE_ANTIDODE // seems neat enough to match the iOS way
});

frappe.desktop.wrapper.on('mousedown', '.app-icon', () => {
timer_id = setTimeout(() => {
frappe.desktop.wiggling = true;
// hide all notifications.
$notis.hide();
$cases.each((i) => {
const $case = $($cases[i]);
const template =
`
<div class="circle module-remove" style="background-color:#E0E0E0; color:#212121">
<div class="circle-text">
<b>
&times
</b>
</div>
</div>
`;

$case.append(template);
const $close = $case.find('.module-remove');
const name = $case.attr('title');
$close.click(() => {
// good enough to create dynamic dialogs?
const dialog = new frappe.ui.Dialog({
title: __(`Hide ${name}?`)
});
dialog.set_primary_action(__('Hide'), () => {
frappe.call({
method: 'frappe.desk.doctype.desktop_icon.desktop_icon.hide',
args: { name: name },
freeze: true,
callback: (response) =>
{
if ( response.message ) {
location.reload();
}
}
})

dialog.hide();
clearWiggle();
});
// Hacks, Hacks and Hacks.
var $cancel = dialog.get_close_btn();
$cancel.click(() => {
clearWiggle();
});
$cancel.html(__(`Cancel`));

dialog.show();
});
});
$icons.trigger('startRumble');
}, DURATION_LONG_PRESS);
});
frappe.desktop.wrapper.on('mouseup mouseleave', '.app-icon', () => {
clearTimeout(timer_id);
});

// also stop wiggling if clicked elsewhere.
$('body').click((event) => {
if ( frappe.desktop.wiggling ) {
const $target = $(event.target);
// our target shouldn't be .app-icons or .close
const $parent = $target.parents('.case-wrapper');
if ( $parent.length == 0 )
clearWiggle();
}
});
// end wiggle
},

open_module: function(parent) {


+ 13
- 0
frappe/desk/doctype/desktop_icon/desktop_icon.py 파일 보기

@@ -404,3 +404,16 @@ palette = (
('#4F8EA8', 1),
('#428B46', 1)
)

@frappe.whitelist()
def hide(name, user = None):
if not user:
user = frappe.session.user

try:
set_hidden(name, user, hidden = 1)
clear_desktop_icons_cache()
except Exception:
return False

return True

+ 8
- 1
frappe/public/build.json 파일 보기

@@ -23,6 +23,7 @@
"public/js/frappe/misc/rating_icons.html"
],
"js/control.min.js": [
"public/js/frappe/ui/capture.js",
"public/js/frappe/form/controls/base_control.js",
"public/js/frappe/form/controls/base_input.js",
"public/js/frappe/form/controls/data.js",
@@ -55,12 +56,15 @@
"js/dialog.min.js": [
"public/js/frappe/dom.js",
"public/js/frappe/ui/modal.html",

"public/js/frappe/form/formatters.js",
"public/js/frappe/form/layout.js",
"public/js/frappe/ui/field_group.js",
"public/js/frappe/form/link_selector.js",
"public/js/frappe/form/multi_select_dialog.js",
"public/js/frappe/ui/dialog.js",
"public/js/frappe/ui/capture.js",

"public/js/frappe/form/controls/base_control.js",
"public/js/frappe/form/controls/base_input.js",
"public/js/frappe/form/controls/data.js",
@@ -130,7 +134,9 @@
"public/js/lib/jSignature.min.js",
"public/js/frappe/translate.js",
"public/js/lib/datepicker/datepicker.min.js",
"public/js/lib/datepicker/locale-all.js"
"public/js/lib/datepicker/locale-all.js",
"public/js/lib/jquery.jrumble.min.js",
"public/js/lib/webcam.min.js"
],
"js/desk.min.js": [
"public/js/frappe/class.js",
@@ -168,6 +174,7 @@
"public/js/frappe/form/link_selector.js",
"public/js/frappe/form/multi_select_dialog.js",
"public/js/frappe/ui/dialog.js",
"public/js/frappe/ui/capture.js",
"public/js/frappe/ui/app_icon.js",

"public/js/frappe/model/model.js",


+ 4
- 2
frappe/public/js/frappe/form/controls/color.js 파일 보기

@@ -36,9 +36,11 @@ frappe.ui.form.ControlColor = frappe.ui.form.ControlData.extend({
set_formatted_input: function(value) {
this._super(value);

if(!value) value = '#ffffff';
if (!value) value = '#FFFFFF';
const contrast = frappe.ui.color.get_contrast_color(value);

this.$input.css({
"background-color": value
"background-color": value, "color": contrast
});
},
bind_events: function () {


+ 22
- 1
frappe/public/js/frappe/form/controls/text_editor.js 파일 보기

@@ -7,6 +7,23 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
this.setup_image_dialog();
this.setting_count = 0;
},
render_camera_button: (context) => {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-camera"/>',
tooltip: 'Camera',
click: () => {
const capture = new frappe.ui.Capture();
capture.open();

capture.click((data) => {
context.invoke('editor.insertImage', data);
});
}
});

return button.render();
},
make_editor: function() {
var me = this;
this.editor = $("<div>").appendTo(this.input_area);
@@ -25,9 +42,12 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
['color', ['color']],
['para', ['ul', 'ol', 'paragraph', 'hr']],
//['height', ['height']],
['media', ['link', 'picture', 'video', 'table']],
['media', ['link', 'picture', 'camera', 'video', 'table']],
['misc', ['fullscreen', 'codeview']]
],
buttons: {
camera: this.render_camera_button,
},
keyMap: {
pc: {
'CTRL+ENTER': ''
@@ -80,6 +100,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
'outdent': 'fa fa-outdent',
'arrowsAlt': 'fa fa-arrows-alt',
'bold': 'fa fa-bold',
'camera': 'fa fa-camera',
'caret': 'caret',
'circle': 'fa fa-circle',
'close': 'fa fa-close',


+ 94
- 0
frappe/public/js/frappe/ui/capture.js 파일 보기

@@ -0,0 +1,94 @@
frappe.ui.Capture = class
{
constructor (options = { })
{
this.options = Object.assign({}, frappe.ui.Capture.DEFAULT_OPTIONS, options);
this.dialog = new frappe.ui.Dialog();
this.template =
`
<div class="text-center">
<div class="img-thumbnail" style="border: none;">
<div id="frappe-capture"/>
</div>
</div>

<div id="frappe-capture-btn-toolbar" style="padding-top: 15px; padding-bottom: 15px;">
<div class="text-center">
<div id="frappe-capture-btn-toolbar-snap">
<a id="frappe-capture-btn-snap">
<i class="fa fa-fw fa-2x fa-circle-o"/>
</a>
</div>
<div class="btn-group" id="frappe-capture-btn-toolbar-knap">
<button class="btn btn-default" id="frappe-capture-btn-discard">
<i class="fa fa-fw fa-arrow-left"/>
</button>
<button class="btn btn-default" id="frappe-capture-btn-accept">
<i class="fa fa-fw fa-arrow-right"/>
</button>
</div>
</div>
</div>
`;
$(this.dialog.body).append(this.template);

this.$btnBarSnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-snap');
this.$btnBarKnap = $(this.dialog.body).find('#frappe-capture-btn-toolbar-knap');
this.$btnBarKnap.hide();

Webcam.set(this.options);
}

open ( )
{
this.dialog.show();

Webcam.attach('#frappe-capture');
}

freeze ( )
{
this.$btnBarSnap.hide();
this.$btnBarKnap.show();
Webcam.freeze();
}

unfreeze ( )
{
this.$btnBarSnap.show();
this.$btnBarKnap.hide();

Webcam.unfreeze();
}

click (callback)
{
$(this.dialog.body).find('#frappe-capture-btn-snap').click(() => {
this.freeze();

$(this.dialog.body).find('#frappe-capture-btn-discard').click(() => {
this.unfreeze();
});

$(this.dialog.body).find('#frappe-capture-btn-accept').click(() => {
Webcam.snap((data) => {
callback(data);
});

this.hide();
});
});
}

hide ( )
{
Webcam.reset();

$(this.dialog.$wrapper).remove();
}
};
frappe.ui.Capture.DEFAULT_OPTIONS =
{
width: 480, height: 320, flip_horiz: true
};

+ 2
- 0
frappe/public/js/lib/jquery.jrumble.min.js 파일 보기

@@ -0,0 +1,2 @@
/* jRumble v1.3 - http://jackrugile.com/jrumble - MIT License */
(function(f){f.fn.jrumble=function(g){var a=f.extend({x:2,y:2,rotation:1,speed:15,opacity:false,opacityMin:0.5},g);return this.each(function(){var b=f(this),h=a.x*2,i=a.y*2,k=a.rotation*2,g=a.speed===0?1:a.speed,m=a.opacity,n=a.opacityMin,l,j,o=function(){var e=Math.floor(Math.random()*(h+1))-h/2,a=Math.floor(Math.random()*(i+1))-i/2,c=Math.floor(Math.random()*(k+1))-k/2,d=m?Math.random()+n:1,e=e===0&&h!==0?Math.random()<0.5?1:-1:e,a=a===0&&i!==0?Math.random()<0.5?1:-1:a;b.css("display")==="inline"&&(l=true,b.css("display","inline-block"));b.css({position:"relative",left:e+"px",top:a+"px","-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity="+d*100+")",filter:"alpha(opacity="+d*100+")","-moz-opacity":d,"-khtml-opacity":d,opacity:d,"-webkit-transform":"rotate("+c+"deg)","-moz-transform":"rotate("+c+"deg)","-ms-transform":"rotate("+c+"deg)","-o-transform":"rotate("+c+"deg)",transform:"rotate("+c+"deg)"})},p={left:0,top:0,"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",filter:"alpha(opacity=100)","-moz-opacity":1,"-khtml-opacity":1,opacity:1,"-webkit-transform":"rotate(0deg)","-moz-transform":"rotate(0deg)","-ms-transform":"rotate(0deg)","-o-transform":"rotate(0deg)",transform:"rotate(0deg)"};b.bind({startRumble:function(a){a.stopPropagation();clearInterval(j);j=setInterval(o,g)},stopRumble:function(a){a.stopPropagation();clearInterval(j);l&&b.css("display","inline");b.css(p)}})})}})(jQuery);

+ 2
- 0
frappe/public/js/lib/webcam.min.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 0
- 9
license.txt 파일 보기

@@ -1,9 +0,0 @@
The MIT License (MIT)

Copyright (c) 2016 Frappe Technologies Pvt. Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 1
- 1
requirements.txt 파일 보기

@@ -6,7 +6,7 @@ httplib2
jinja2
markdown2
markupsafe
mysqlclient==1.3.10
-e git+https://github.com/frappe/mysqlclient-python.git@1.3.12#egg=mysqlclient
python-geoip
python-geoip-geolite2
python-dateutil


+ 35
- 2
setup.py 파일 보기

@@ -1,3 +1,7 @@
# imports - standard imports
import os, shutil
from distutils.command.clean import clean as Clean

from setuptools import setup, find_packages
from pip.req import parse_requirements
import re, ast
@@ -11,6 +15,31 @@ with open('frappe/__init__.py', 'rb') as f:

requirements = parse_requirements("requirements.txt", session="")

class CleanCommand(Clean):
def run(self):
Clean.run(self)

basedir = os.path.abspath(os.path.dirname(__file__))

for relpath in ['build', '.cache', '.coverage', 'dist', 'frappe.egg-info']:
abspath = os.path.join(basedir, relpath)
if os.path.exists(abspath):
if os.path.isfile(abspath):
os.remove(abspath)
else:
shutil.rmtree(abspath)

for dirpath, dirnames, filenames in os.walk(basedir):
for filename in filenames:
_, extension = os.path.splitext(filename)
if extension in ['.pyc']:
abspath = os.path.join(dirpath, filename)
os.remove(abspath)
for dirname in dirnames:
if dirname in ['__pycache__']:
abspath = os.path.join(dirpath, dirname)
shutil.rmtree(abspath)

setup(
name='frappe',
version=version,
@@ -21,5 +50,9 @@ setup(
zip_safe=False,
include_package_data=True,
install_requires=[str(ir.req) for ir in requirements],
dependency_links=[str(ir._link) for ir in requirements if ir._link]
)
dependency_links=[str(ir._link) for ir in requirements if ir._link],
cmdclass = \
{
'clean': CleanCommand
}
)

불러오는 중...
취소
저장