diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index 4171a39..6505c5c 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ diff --git a/article/__pycache__/urls.cpython-36.pyc b/article/__pycache__/urls.cpython-36.pyc index febf41e..4cc21fa 100644 Binary files a/article/__pycache__/urls.cpython-36.pyc and b/article/__pycache__/urls.cpython-36.pyc differ diff --git a/article/__pycache__/views.cpython-36.pyc b/article/__pycache__/views.cpython-36.pyc index c7564ac..c630eda 100644 Binary files a/article/__pycache__/views.cpython-36.pyc and b/article/__pycache__/views.cpython-36.pyc differ diff --git a/article/models.py b/article/models.py index 682ae7a..347fb3e 100644 --- a/article/models.py +++ b/article/models.py @@ -2,7 +2,7 @@ from django.db import models from tinymce.models import HTMLField,TinyMCE from django.contrib.auth.models import User -from django.forms import ModelForm,Textarea +from django.forms import * from userpage.models import * #from django.conf import settings #from tagging.fields import TagField @@ -50,9 +50,15 @@ class Meta: class ArticleForm(ModelForm): class Meta: model = Article - fields = ['title','author','section','tag','cover','detail'] + fields = ['title','author','author_id','section','tag','cover','detail'] widgets = { - 'detail':TinyMCE(attrs={'cols':'100%','rows':50}), + 'detail':TinyMCE(attrs={'cols':'100%','rows':30}), + 'cover':ClearableFileInput(attrs={'style':'width:50%','class':'form-control','placeholder':"封面"}), + 'tag':TextInput(attrs={'class':'form-control','placeholder':"添加标签,回车确认",'data-role':'tagsinput'}), + 'author':TextInput(attrs={'class':'form-control','placeholder':"署名"}), + 'title':TextInput(attrs={'style':'width:50%','class':'form-control','placeholder':"标题"}), + 'section':widgets.Select(choices=Section.objects.values_list('id','name'),attrs={'class':'form-control','placeholder':"标题"}), + } @@ -62,7 +68,7 @@ class Comment(models.Model): user = models.ForeignKey(Profile,on_delete=models.CASCADE,default=0) comment_time = models.DateTimeField(auto_now_add=True,editable=False) comment = HTMLField() - ip = models.GenericIPAddressField() + ip = models.GenericIPAddressField(blank=True,null=True,default='0.0.0.0') clickcount = models.IntegerField(default=0) refer = models.CharField(max_length=5096,default='none') agent = models.CharField(max_length=5096,default='none') diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index ef1c5d0..c962ae4 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -34,30 +34,37 @@
评论
+评论
{% for i in comments %}
{% if art %}{{art.title}}{% endif %}
发布评论
+ {% if messages %} {% endif %} -{% if art %}{{art.title}}{% endif %}
+广告位
评论
- - {% for i in comments %} -{{operation}}文章
+ {% if messages %} {% endif %} - +广告位
tagsinput('items')
an +array of the original items is returned. + +### True multi value support +Other implementations just concatenate the values to a comma separated string. +This results inval()
returning just this string, and when +submitting the form, only one big, concatenated value is sent in the request. + +Bootstrap Tags Input provides true multivalue support. Just use a +<select multiple />
as your input element, and +val()
will return an array of the tag values. When submitting the +form, an array of values will be sent with the request. + +### Typeahead support +Integrates with Twitter Bootstraps' 2.3.2 typeahead, or use custom typeahead when using Bootstrap 3. + +## Development +Install dependencies: + +Test: + +Build: + +Current Library Versions: + +- Bootstrap: 3.3.5 +- jQuery: 2.1.4 +- Typeahead: 0.11.1 + +Libraries for testing go in the **/lib** directory. + +## History +- 0.8.0 + - [Add possibility skip "change" event after "add", "remove", "removeAll"](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/429) + - [Please add version to header of non-minified version.](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/438) +- 0.7.1 + - [allowDuplicates not working](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/419) + - [tag text appears when typeahead input looses focus](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/386) + - [Remove duplicate method `removeAll` in manual](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/427) +- 0.7.0 + - [.tt-menu etc. styles should be included in bootstrap-tagsinput.css by default](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/426) + - [Comma character carried over to new tag input when used as separator](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/422) + - [Emails in multi select are being duplicated](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/399) + - [The 'itemAdded' Event run on Load the Page!](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/369) +- 0.6.1 + - [Source maps fix](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/371) +- 0.6.0 + - [Allow form submissions when pressing enter if field is empty. Controlled by option](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/368) + - [Ability to set different or multiple delimiters](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/397) + - [No longer triggering itemRemoved when the field is already empty](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/405) +- 0.5 + - [Added an optional 3rd parameter to the "add" and "remove" methods](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/298) +- 0.4 + - [Fix typeahead when using Bootstrap 3](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/73) +- 0.3.13 + - [#5: Trigger events on original input/select](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/5) + - Loads of fixes merged with help of @janvt, @rlidwka and @kuraga: thanks for helping me out! +- 0.3.9 + - [#48: Type ahead stops when entering second character](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/48) +- 0.3.8 + - [#43: Add support for placeholder](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/43) + - [#46: ie 8 compatibility, replace indexOf method](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/46) +- 0.3.7 + - [#39: flash when duplicate is entered](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/39) +- 0.3.6 + - [#34: Error in ReloadPage](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/34) +- 0.3.5 + - [#10: confirmKeys option](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/10) +- 0.3.4 + - [#24: Add bsTagsInput angular directive & example for bootstrap3 with typeahea...](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/24) + - [#28: Limit number of tags, enable/disable input](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/28) + - [#33: Avoid conflict with other selects when checking for value presence](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/pull/33) + +## License +This project is licensed under [MIT](https://raw.github.com/bootstrap-tagsinput/bootstrap-tagsinput/master/LICENSE "Read more about the MIT license"). diff --git a/static/bootstrap/js/bootstrap-tagsinput-master/bootstrap-tagsinput.jquery.json b/static/bootstrap/js/bootstrap-tagsinput-master/bootstrap-tagsinput.jquery.json new file mode 100644 index 0000000..ac64c17 --- /dev/null +++ b/static/bootstrap/js/bootstrap-tagsinput-master/bootstrap-tagsinput.jquery.json @@ -0,0 +1,27 @@ +{ + "name": "bootstrap-tagsinput", + "version": "0.8.0", + "title": "Bootstrap Tags Input", + "author": { + "name": "Tim Schlechter" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://opensource.org/licenses/MIT" + } + ], + "dependencies": { + "jquery": "*" + }, + "description": "jQuery plugin providing a Twitter Bootstrap user interface for managing tags.", + "keywords": [ + "tags", + "bootstrap", + "input", + "select", + "form" + ], + "download": "http://timschlechter.github.io/bootstrap-tagsinput/build/bootstrap-tagsinput.zip", + "homepage": "http://timschlechter.github.io/bootstrap-tagsinput/examples/" +} \ No newline at end of file diff --git a/static/bootstrap/js/bootstrap-tagsinput-master/bower.json b/static/bootstrap/js/bootstrap-tagsinput-master/bower.json new file mode 100644 index 0000000..e44273c --- /dev/null +++ b/static/bootstrap/js/bootstrap-tagsinput-master/bower.json @@ -0,0 +1,42 @@ +{ + "name": "bootstrap-tagsinput", + "version": "0.5.0", + "homepage": "https://github.com/TimSchlechter/bootstrap-tagsinput", + "authors": [ + "Tim Schlechter", + "Luckner Jr Jean-Baptiste" + ], + "description": "jQuery plugin providing a Twitter Bootstrap user interface for managing tags.", + "main": [ + "dist/bootstrap-tagsinput.js", + "dist/bootstrap-tagsinput.css" + ], + "keywords": [ + "tags", + "bootstrap", + "input", + "select", + "form" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "lib", + "test" + ], + "dependencies": { + "jquery": "~2.1.1" + }, + "devDependencies": { + "bootstrap-3": "bootstrap#~3.2.0", + "bootstrap-2.3.2": "bootstrap#~2.3.2", + "angular": "~1.2.21", + "typeahead.js": "~0.10.4", + "jasmine": "~2.0.1" + }, + "resolutions": { + "jquery": ">= 1.9.0" + } +} diff --git a/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.js b/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.js new file mode 100644 index 0000000..b849848 --- /dev/null +++ b/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.js @@ -0,0 +1,92 @@ +/* + * bootstrap-tagsinput v0.8.0 + * + */ + +angular.module('bootstrap-tagsinput', []) +.directive('bootstrapTagsinput', [function() { + + function getItemProperty(scope, property) { + if (!property) + return undefined; + + if (angular.isFunction(scope.$parent[property])) + return scope.$parent[property]; + + return function(item) { + return item[property]; + }; + } + + return { + restrict: 'EA', + scope: { + model: '=ngModel' + }, + template: '', + replace: false, + link: function(scope, element, attrs) { + $(function() { + if (!angular.isArray(scope.model)) + scope.model = []; + + var select = $('select', element); + var typeaheadSourceArray = attrs.typeaheadSource ? attrs.typeaheadSource.split('.') : null; + var typeaheadSource = typeaheadSourceArray ? + (typeaheadSourceArray.length > 1 ? + scope.$parent[typeaheadSourceArray[0]][typeaheadSourceArray[1]] + : scope.$parent[typeaheadSourceArray[0]]) + : null; + + select.tagsinput(scope.$parent[attrs.options || ''] || { + typeahead : { + source : angular.isFunction(typeaheadSource) ? typeaheadSource : null + }, + itemValue: getItemProperty(scope, attrs.itemvalue), + itemText : getItemProperty(scope, attrs.itemtext), + confirmKeys : getItemProperty(scope, attrs.confirmkeys) ? JSON.parse(attrs.confirmkeys) : [13], + tagClass : angular.isFunction(scope.$parent[attrs.tagclass]) ? scope.$parent[attrs.tagclass] : function(item) { return attrs.tagclass; } + }); + + for (var i = 0; i < scope.model.length; i++) { + select.tagsinput('add', scope.model[i]); + } + + select.on('itemAdded', function(event) { + if (scope.model.indexOf(event.item) === -1) + scope.model.push(event.item); + }); + + select.on('itemRemoved', function(event) { + var idx = scope.model.indexOf(event.item); + if (idx !== -1) + scope.model.splice(idx, 1); + }); + + // create a shallow copy of model's current state, needed to determine + // diff when model changes + var prev = scope.model.slice(); + scope.$watch("model", function() { + var added = scope.model.filter(function(i) {return prev.indexOf(i) === -1;}), + removed = prev.filter(function(i) {return scope.model.indexOf(i) === -1;}), + i; + + prev = scope.model.slice(); + + // Remove tags no longer in binded model + for (i = 0; i < removed.length; i++) { + select.tagsinput('remove', removed[i]); + } + + // Refresh remaining tags + select.tagsinput('refresh'); + + // Add new items in model as tags + for (i = 0; i < added.length; i++) { + select.tagsinput('add', added[i]); + } + }, true); + }); + } + }; +}]); diff --git a/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.min.js b/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.min.js new file mode 100644 index 0000000..a1aecbc --- /dev/null +++ b/static/bootstrap/js/bootstrap-tagsinput-master/dist/bootstrap-tagsinput-angular.min.js @@ -0,0 +1,7 @@ +/* + * bootstrap-tagsinput v0.8.0 + * + */ + +angular.module("bootstrap-tagsinput",[]).directive("bootstrapTagsinput",[function(){function a(a,b){if(b)return angular.isFunction(a.$parent[b])?a.$parent[b]:function(a){return a[b]}}return{restrict:"EA",scope:{model:"=ngModel"},template:"",replace:!1,link:function(b,c,d){$(function(){angular.isArray(b.model)||(b.model=[]);var e=$("select",c),f=d.typeaheadSource?d.typeaheadSource.split("."):null,g=f?f.length>1?b.$parent[f[0]][f[1]]:b.$parent[f[0]]:null;e.tagsinput(b.$parent[d.options||""]||{typeahead:{source:angular.isFunction(g)?g:null},itemValue:a(b,d.itemvalue),itemText:a(b,d.itemtext),confirmKeys:a(b,d.confirmkeys)?JSON.parse(d.confirmkeys):[13],tagClass:angular.isFunction(b.$parent[d.tagclass])?b.$parent[d.tagclass]:function(a){return d.tagclass}});for(var h=0;h+-
+ Code on Github
+
+ -
+ Bootstrap 3
+
+ -
+ Download (latest)
+
+
++ Tweet + + + + + + + + + +
+Bootstrap Tags Input
+jQuery plugin providing a Twitter Bootstrap user interface for managing tags
+ +Examples
+Markup
++ Just add
+data-role="tagsinput"
to your input field to automatically change it to a tags input field. +$("input").val()
$("input").tagsinput('items')
True multi value
++ Use a
+<select multiple />
as your input element for a tags input, to gain true multivalue support. Instead of a comma separated string, the values will be set in an array. Existing<option />
elements will automatically be set as tags. This makes it also possible to create tags containing a comma. +$("select").val()
$("select").tagsinput('items')
Typeahead
+$("input").val()
$("input").tagsinput('items')
Objects as tags
++ Instead of just adding strings as tags, bind objects to your tags. This makes it possible to set id values in your input field's value, instead of just the tag's text. +
+$("input").val()
$("input").tagsinput('items')
Categorizing tags
++ You can set a fixed css class for your tags, or determine dynamically by providing a custom function. +
+$("input").val()
$("input").tagsinput('items')
AngularJS support
++ Include
+bootstrap-tagsinput-angular.js
and register the 'bootstrap-tagsinput' in your Angular JS application to use the bootstrap-tagsinput directive. +$scope.cities
$("select").val()
$("select").tagsinput('items')
Options
+tagClass
Classname for the tags, or a function returning a classname
+ + +itemValue
When adding objects as tags, itemValue must be set to the name of the property containing the item's value, or a function returning an item's value.
+ + +itemText
When adding objects as tags, you can set itemText to the name of the property of item to use for a its tag's text. You may also provide a function which returns an item's value. When this options is not set, the value of
+ +itemValue
will be used. + + +confirmKeys
Array of keycodes which will add a tag when typing in the input. (default: [13, 188], which are ENTER and comma)
+ +maxTags
When set, no more than the given number of tags are allowed to add (default: undefined). When maxTags is reached, a class 'bootstrap-tagsinput-max' is placed on the tagsinput element. (default: undefined)
+ +maxChars
Defines the maximum length of a single tag. (default: undefined)
+ +trimValue
When true, automatically removes all whitespace around tags. (default: false)
+ +allowDuplicates
When true, the same tag can be added multiple times. (default: false)
+ +maxChars
Defines the maximum length of a single tag.
+ +freeInput
Allow creating tags which are not returned by typeahead's source (default: true)
+typeahead
Object containing typeahead specific options
source
An array (or function returning a promise or array), which will be used as source for a typeahead. +
+ +onTagExists
Function invoked when trying to add an item which allready exists. By default, the existing tag hides and fades in. +
+Methods
+add
Adds a tag
+ + + + +remove
Removes a tag
+ + + + +removeAll
Removes all tags
+ + +focus
Sets focus in the tagsinput
+ + +input
Returns the tagsinput's internal <input />, which is used for adding tags. You could use this to add your own typeahead behaviour for example.
+ + + +refresh
Refreshes the tags input UI. This might be usefull when you're adding objects as tags. When an object's text changes, you'll have to refresh to update the matching tag's text.
+ + +destroy
Removes tagsinput behaviour
+ + +Events
+beforeItemAdd
itemAdded
beforeItemRemove
itemRemoved
Bootstrap Tags Input
+jQuery plugin providing a Twitter Bootstrap user interface for managing tags
++ Code on Github + Bootstrap 2.3.2 + Download +
++
+-
+
+
+ -
+
+
+ -
+ Tweet
+
+
+ -
+
+
+
+
+ +Examples
+Markup
+Just add
+data-role="tagsinput"
to your input field to automatically change it to a tags input field.$("input").val()
$("input").tagsinput('items')
True multi value
++ Use a
+<select multiple />
as your input element for a tags input, to gain true multivalue support. Instead of a comma separated string, the values will be set in an array. Existing<option />
elements will automatically be set as tags. This makes it also possible to create tags containing a comma. +$("select").val()
$("select").tagsinput('items')
Typeahead
+ Typeahead is not included in Bootstrap 3, so you'll have to include your own typeahead library. I'd recommed typeahead.js. An example of using this is shown below. + +$("input").val()
$("input").tagsinput('items')
Objects as tags
++ Instead of just adding strings as tags, bind objects to your tags. This makes it possible to set id values in your input field's value, instead of just the tag's text. +
+$("input").val()
$("input").tagsinput('items')
Categorizing tags
++ You can set a fixed css class for your tags, or determine dynamically by providing a custom function. +
+$("input").val()
$("input").tagsinput('items')
Options
+tagClass
Classname for the tags, or a function returning a classname
+ + +itemValue
When adding objects as tags, itemValue must be set to the name of the property containing the item's value, or a function returning an item's value.
+ + +itemText
When adding objects as tags, you can set itemText to the name of the property of item to use for a its tag's text. You may also provide a function which returns an item's value. When this options is not set, the value of
+ +itemValue
will be used. + + +confirmKeys
Array of keycodes which will add a tag when typing in the input. (default: [13, 188], which are ENTER and comma)
+ +maxTags
When set, no more than the given number of tags are allowed to add (default: undefined). When maxTags is reached, a class 'bootstrap-tagsinput-max' is placed on the tagsinput element.
+ +maxChars
Defines the maximum length of a single tag. (default: undefined)
+ +trimValue
When true, automatically removes all whitespace around tags. (default: false)
+ +allowDuplicates
When true, the same tag can be added multiple times. (default: false)
+ +focusClass
When the input container has focus, the class specified by this config option will be applied to the container
+ +freeInput
Allow creating tags which are not returned by typeahead's source (default: true)
+typeahead
Object containing typeahead specific options
source
An array (or function returning a promise or array), which will be used as source for a typeahead. + + +
+ +cancelConfirmKeysOnEmpty
Boolean value controlling whether form submissions get processed when pressing enter in a field converted to a tagsinput (default: false). +
+onTagExists
Function invoked when trying to add an item which allready exists. By default, the existing tag hides and fades in. +
+Methods
+add
Adds a tag
+ + + + + + Optionally, you can pass a 3rd parameter (object or value) to theadd
method to gain more control over the process. The parameter is exposed in theoptions
attribute of the event. + + + + Usage: + + +remove
Removes a tag
+ + + + + + Optionally, you can pass a 3rd parameter (object or value) to theremove
method to gain more control over the process. The parameter is exposed in theoptions
attribute of the event. + + + + Usage: + + +removeAll
Removes all tags
+ + +focus
Sets focus in the tagsinput
+ + +input
Returns the tagsinput's internal <input />, which is used for adding tags. You could use this to add your own typeahead behaviour for example.
+ + + +refresh
Refreshes the tags input UI. This might be usefull when you're adding objects as tags. When an object's text changes, you'll have to refresh to update the matching tag's text.
+ + +destroy
Removes tagsinput behaviour
+ + +Events
+itemAddedOnInit
beforeItemAdd
itemAdded
beforeItemRemove
itemRemoved
',item:'