diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3c3629e..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/README.md b/README.md index 9cc5d9f..bfda8b0 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Examples: http://ipsum.ir/design/p/2 http://ipsum.ir/normal/c/250 - http://ipsum.ir/design/w/10 + http://ipsum.ir/news/w/10 ## Contributing diff --git a/count.json b/count.json new file mode 100644 index 0000000..573541a --- /dev/null +++ b/count.json @@ -0,0 +1 @@ +0 diff --git a/economy.json b/economy.json deleted file mode 100644 index d3562d0..0000000 --- a/economy.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - "مسکن", - "مشتری", - "وام", - "سهام", - "شرکت", - "حقوق", - "درآمد", - "صنعت", - "تجارت", - "یورو", - "ریال", - "دلار", - "قیمت", - "خرید", - "بورس", - "پول", - "بانک", - "اقتصاد", - "کالا", - "گمرک", - "سهامداران", - "تورم", - "سود", - "هر اونس طلا", - "رکود", - "نرخ", - "نفت", - "عمران", - "بیمه" -] \ No newline at end of file diff --git a/geographic.json b/geographic.json deleted file mode 100644 index 2e129c8..0000000 --- a/geographic.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - "کوه", - "زلزله", - "اختر شناسی", - "پدیده های انسانی", - "خاک", - "توپوگرافی", - "سیل", - "جغرافیا", - "آتشفشان", - "دانش نقشه برداری", - "عصر کاوش", - "آب و هوا", - "گردباد", - "ابن فضلان", - "پدیده های طبیعی", - "موقعیت", - "جنگل", - "اورست", - "نیم کره ی شمالی", - "قله", - "رود", - "محیط زیست", - "بوم", - "جغرافی دان", - "اقیانوس", - "وارونگی هوا", - "آبشار", - "اقلیم شناسی", - "گسل", - "سهند" -] \ No newline at end of file diff --git a/history.json b/history.json deleted file mode 100644 index 8813b76..0000000 --- a/history.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - "تاریخ", - "پادشاه", - "تمدن", - "انسان اولیه", - "انقلاب", - "کودتا", - "کوروش", - "کشف قاره آمریکا", - "فبیله", - "آتشکده", - "قوم مایا", - "قرن", - "اشکانیان", - "معماری سلوکیان", - "گذشته", - "بانو آرتا", - "عصر مسیحیت", - "مادها", - "کاخ هترا", - "نهضت پرنی ها", - "شاهنشاهی", - "قیام", - "امپراطور روم", - "ساسانیان", - "داریوش", - "معاصر", - "سپهبد سورنا", - "تبار ایرانی", - "شاهنامه فردوسی", - "سزار" -] \ No newline at end of file diff --git a/ipsum.js b/ipsum.js index cc66a8d..4b5ea6d 100644 --- a/ipsum.js +++ b/ipsum.js @@ -1,13 +1,18 @@ var express = require('express'), - app = express(); + app = express(), + server = require('http').Server(app), + io = require('socket.io')(server), + fs = require('fs'); app.use(express.static(__dirname + '/ipsum', {maxAge: 60*60*24*7})); module.exports.app = app; app.get(/.*\/.*\/.*/, function(req, res) { - res.charset = 'utf-8'; - res.end(go(req.url)); + if(req.url.split('/')[1] != 'socket.io') { + res.charset = 'utf-8'; + res.end(go(req.url)); + } }); if(!String.prototype.repeat) { @@ -38,13 +43,7 @@ var stretch = function stretch(a, n) { var general = require('./general.json'); var dictionary = { 'design': require('./design.json'), - 'news': require('./news.json'), - 'economy': require('./economy.json'), - 'sporty': require('./sporty.json'), - 'social': require('./social.json'), - 'sanitary': require('./sanitary.json'), - 'history': require('./history.json'), - 'geographic': require('./geographic.json') + 'news': require('./news.json') }; var normal = 'لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است. چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد. کتابهای زیادی در شصت و سه درصد گذشته، حال و آینده شناخت فراوان جامعه و متخصصان را می طلبد تا با نرم افزارها شناخت بیستری را برای طراحان رایانه ای و فرهنگ پیشرو در زبان فارسی ایجاد کرد. در این صورت می توان امید داشت که تمام و دشواری موجود در ارائه راهکارها و شرایط سخت تایپ به پایان رسد وزمان مورد نیاز شامل حروفچینی دستاوردهای اصلی و جوابگوی سوالات پیوسته اهل دنیای موجود طراحی اساسا مورد استفاده قرار گیرد.'; @@ -92,9 +91,21 @@ function loremipsum(data) { return s; } } -function go(url) { - var req = url.split('/'); - return loremipsum(req.slice(1)); + +//COUNTER +io.on('connection', function(socket) { + socket.emit('count', +fs.readFileSync('count.json', 'utf8')); +}); +function counter(data) { + var count = data.split(' ').length + (+fs.readFileSync('count.json', 'utf8')); + fs.writeFileSync('count.json', count); + io.emit('count', count); } -app.listen(8888); + +function go(url) { + var req = url.split('/'), + ipsum = loremipsum(req.slice(1)); + counter(ipsum); + return ipsum; +} diff --git a/ipsum/css/main.css b/ipsum/css/main.css index e22a900..5059d94 100644 --- a/ipsum/css/main.css +++ b/ipsum/css/main.css @@ -510,3 +510,10 @@ a[href="#"].running { background-color: rgba(255, 255, 255, 0.2); color: white; } + +.count { + position: fixed; + bottom: 3rem; + left: 3rem; + font-size: 2.2rem; +} diff --git a/ipsum/index.html b/ipsum/index.html index e241bc4..e64fab1 100644 --- a/ipsum/index.html +++ b/ipsum/index.html @@ -16,15 +16,10 @@

دسته بندی

@@ -56,8 +51,13 @@ +
+ تا حالا کلمه ساختم +
+ Fork me on GitHub + diff --git a/ipsum/js/main.js b/ipsum/js/main.js index e52bf00..4932d5b 100644 --- a/ipsum/js/main.js +++ b/ipsum/js/main.js @@ -1,3 +1,5 @@ +var socket = io(); + var $run = $('h1, h3, .options, a'); $('li[contenteditable]').click(function(e) { @@ -39,3 +41,8 @@ function success(ipsum) { selection.removeAllRanges(); selection.addRange(range); } + +//UPDATE COUNT +socket.on('count', function(data) { + $('#count').html(data); +}) diff --git a/package.json b/package.json deleted file mode 100644 index 0b7d161..0000000 --- a/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "ipsum", - "version": "1.0.0", - "description": "The code powering [ipsum.ir](http://ipsum.ir), a categorized ipsum generator with REST API for those who care.", - "main": "ipsum.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://github.com/mdibaiee/ipsum" - }, - "author": "", - "license": "BSD-2-Clause", - "bugs": { - "url": "https://github.com/mdibaiee/ipsum/issues" - }, - "devDependencies": { - "express": "~4.12.4" - } -} diff --git a/sanitary.json b/sanitary.json deleted file mode 100644 index 052cae9..0000000 --- a/sanitary.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - "بهداشت", - "درمانگاه", - "پزشک", - "بیمار", - "پرستار", - "عمل", - "دندان", - "محیط زیست", - "زندگی", - "سلامتی", - "حمام", - "فلج اطفال", - "شفا", - "ویتامین ها", - "سرطان زا", - "شیوع", - "فیوتراپی", - "عینک", - "سمعک", - "تغذیه", - "مسمومیت", - "بیولوژی", - "درمان", - "امنیت غذایی", - "پیشگیری", - "طب سنتی", - "خوراکی", - "پوست", - "دارو", - "مراقبت" -] \ No newline at end of file diff --git a/social.json b/social.json deleted file mode 100644 index f6cbd00..0000000 --- a/social.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - "اجتماع", - "آرامش", - "دانش عمومی", - "راهکار", - "طلاق", - "سلامتی", - "جامعه", - "آینده", - "مشکل", - "فقط", - "اعتیاد", - "مردم", - "آسایش", - "شغل", - "ملت", - "ازدواج", - "خانه", - "کلاه برداری", - "رهبر", - "پدر و مادر", - "خانواده", - "زندگی", - "بهبود", - "مشقت", - "بازار کار", - "فرزند", - "محله", - "دوستی", - "طبقات مردم" -] \ No newline at end of file diff --git a/sporty.json b/sporty.json deleted file mode 100644 index 6abfbff..0000000 --- a/sporty.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - "فوتبال", - "قهرمان", - "پهلوان", - "پیروزی", - "شکست", - "مسابقات", - "کشتی", - "تکواندو", - "مدال", - "المپیک", - "جام جهانی", - "کوهنوردی", - "فدراسیون", - "طلا", - "نفره", - "برنز", - "لیگ", - "باشگاه", - "وزنه", - "دمبل", - "رزمی", - "سرمربی", - "صعود", - "تیم", - "اردو", - "بازیکن", - "ملی پوش", - "افتخار آفرین", - "منتخب", - "سقوط" -] \ No newline at end of file